开发者

How can I access url variable from zend view script instead of controller level?

开发者 https://www.devze.com 2023-03-30 18:42 出处:网络
Example: http://domain.local/user/edit/id/23 controller = user action = edit id = 23 From controller I can easily get a value of the开发者_C百科 request variable \"id\" by writing

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

From controller I can easily get a value of the开发者_C百科 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?


in your view type

Zend_Controller_Front::getInstance()->getRequest()->getParam('id', null);


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消