开发者

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

开发者 https://www.devze.com 2023-01-29 21:35 出处:网络
I know to how to get 开发者_Go百科controller name and action name from layout.phtml file so that i can make dynamic css.Try this:

I know to how to get 开发者_Go百科controller name and action name from layout.phtml file so that i can make dynamic css.


Try this:

Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
Zend_Controller_Front::getInstance()->getRequest()->getActionName();


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! :)


for finding controller name and action name in zend use this in controller

   Zend_Controller_Front::getInstance()->getRequest()->getControllerName()
   Zend_Controller_Front::getInstance()->getRequest()->getActionName()


<?php 
echo $this->headLink()->appendStylesheet($this >baseUrl().'path to your css file without public folder'); 
?>
0

精彩评论

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

关注公众号