0

Example: http://domain.local/user/edit/id/23 controller = user action = edit id = 23

From controller I can easily get a value of the request variable "id" by writing $id = $this->_getParam('id');

But I want to get it from the view script (user/edit.phtml) directly. How is this possible?

2 Answers 2

1

in your view type

Zend_Controller_Front::getInstance()->getRequest()->getParam('id', null);
Sign up to request clarification or add additional context in comments.

Comments

0

You could pass it from the controller to the view:-

In your controller:-

$this->view->id = $this->_getParam('id');

Then in your view it is available with:-

$this->id;

2 Comments

Yes that's really easy. But I wanted it directly. Because I am accessing it from some view partials. So in this case I have to pass it to those partials again from the view script. It's a lot of task to manage. If I could get it from the partial itself then it would be great.
Don't forget that the seperation of view and controller is there for a reason.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.