Zend Framework:我如何将值传递给layout.phtml?

时间:2011-08-28 13:40:56

标签: zend-framework

我可以使用this =>

将值从控制器传递到视图
$this->view->objvalue = $value;

但是如何将值传递给layout.phtml?

我想要一个编辑表的链接。所以我必须使用'id'=> $ getvaluefromsomewhere-> id进行链接。我怎样才能在zend框架中做到这一点?

我将把这个文件放在哪里(My_Layout_Plugin.php)?     

class My_Layout_Plugin extends Zend_Controller_Plugin_Abstract
{
   public function preDispatch(Zend_Controller_Request_Abstract $request)
   {
      $layout = Zend_Layout::getMvcInstance();
      $view = $layout->getView();

      $view->whatever = 'foo';
   }
}

Sending variables to the layout in Zend Framework

1 个答案:

答案 0 :(得分:2)

将它放在library / My / Layout / Plugin.php中,并将其添加到application.ini

resources.frontController.plugins.layout = "My_Layout_Plugin"

请参阅此处Zend framework 1.8 recommended way to register a plugin?