我正在使用 Zend_view/Zend_Layout 但我希望能够根据控制器将脚本附加到整个模板,因此在控制器中我可以执行以下操作:
public function someAction()
{
$something->headScript()->appendFile('script.js','text/javascript');
// etc etc
}
我已经像这样启用 Zend_view/Zend_Layout:
在 application.ini 中:
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
在 Bootstrap.php 中:
protected function _initView()
{
$view = new Zend_View();
$view->doctype('XHTML1_STRICT');
$view->headTitle('zend layout tester');
// Add it to the ViewRenderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
'ViewRenderer'
);
$viewRenderer->setView($view);
// Return it, so that it can be stored by the bootstrap
return $view;
}