Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access controller name and action name form layout file in zend framework

I know to how to get controller name and action name from layout.phtml file so that i can make dynamic css.

like image 904
Santosh Linkha Avatar asked Dec 09 '10 09:12

Santosh Linkha


2 Answers

Try this:

Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
Zend_Controller_Front::getInstance()->getRequest()->getActionName();
like image 150
Ashley Avatar answered Nov 02 '22 18:11

Ashley


You shouldn't really have logic in your layout.

Best inject your css from your controller using the headlink container.

So in your controller...

$this->view->headLink()->appendStylesheet('custom_stylesheet.css');

And in your layout...

echo $this->headLink();

Simple as that! :)

like image 6
mapsi Avatar answered Nov 02 '22 18:11

mapsi