Param view helper
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 2526 27 28 | <?php /** * Retrieves requet param * * @category Ds * @package View * @subpackage Helper * @author Michal "Techi" Vrchota <michal.vrchota@gmail.com> * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU General Public License v 3.0 */ require_once 'Zend/View/Helper/Abstract.php'; class Ds_View_Helper_Param extends Zend_View_Helper_Abstract { /** * Retrieve param * * @param string $name key * @return string */ public function param($name) { return Zend_Controller_Front::getInstance()->getRequest()->getParam($name); } } |
Comments
For those of us that try to limit our use of controllers as much as possible, accessing "params" directly in a view script is a very common occurrence.
Well I agree that is best to avoid working with params directly in template however sometimes it can be usefull
i.e. highlight link which represents current controller/action - is better to perform the task in template rather then in controller
You must login before commenting on a snippet. If you do not have an account, please register.
2 years ago
So simple, yet so extremely convenient. If you uncoupled it from the Zend_Controller_Front and allowed it to fall back on standard superglobals, it would be more helpful to a greater number of people.