i want to add a conditional statement to my layout that tests:
- the controller param in the url
- the existence of a zend_auth()
what’s the best way to achieve that? i have tried testing the $this->_getParam('controller') in the layout but got an error. i could just set that variable in all the controllers but that seems kind of dumb. how to best set a variable that i could use later from the layout with some conditional logic? or should i instead add my conditional logic that is inside a view helper and then loaded into the layout?
Edit The controller shouldn’t be a URL parameter, unless you are doing some very strange routing. If you were getting a GET (or POST) variable, you would use
->getParam()on the request object,Zend_Controller_Front::getInstance()->getRequest(), as used below. But the controller is a separate property of that request object.This is the auth part:
This is the controller part: