Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework - need to access a GET parameter from a view

I am using the Zend framework and what I need is to construct a url in my view. Normally in regular php code I'd just grab the GET Variable by using the global $_GET. However with Zend I'm setting it to clean URIs so :

?ac=list&filter=works&page=2

Looks like index/ac/list/filter/works/page/2

In my view I'm setting a links cs such that if the GET variable filter equals works then the color of that link would be different and it would point to the same page only linked as so:

index/ac/list/filter/extra/page/2

And like wise I have a number of other links all which just one GET value - how do I set this up - I am using the Zend framework.

like image 812
Ali Avatar asked Feb 18 '10 11:02

Ali


1 Answers

To access a request variable direct in the view you could do:

Zend_Controller_Front::getInstance()->getRequest()->getParam('key');

But as others have said, this is not a good idea. It may be easier, but consider other options:

  • set the view variable in the controller
  • write a view helper that pulls the variable from the request object
like image 53
Luiz Damim Avatar answered Oct 22 '22 06:10

Luiz Damim