如何在zend框架中访问控制器名称和操作名称表单布局文件

时间:2010-12-09 09:26:23

标签: zend-framework

我知道如何从layout.phtml文件中获取控制器名称和操作名称,以便我可以制作动态css。

4 个答案:

答案 0 :(得分:45)

试试这个:

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

答案 1 :(得分:6)

你的布局中不应该有逻辑。

Best使用headlink容器从控制器中注入你的css。

所以在你的控制器......

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

在你的布局中......

echo $this->headLink();

简单就是这样! :)

答案 2 :(得分:0)

在zend中查找控制器名称和操作名称在控制器中使用它

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

答案 3 :(得分:-1)

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