I am trying the Reference Guide in framework.zend.com 7.9.3
to construct an plugin to append header and footer, but it was reported error:
PHP Code:
Uncaught exception 'Zend_View_Exception' with message 'script 'header.phtml' not found in path (../views/scripts/scripts/)' in /opt/lampp/lib/Zend/View/Abstract.php:856
I guess it caused by the
setBasePath() in the plugin class, but i have tried ../views, views ....etc and the error message is reported similar with ../view/scripts which the offical site suggested.
How can I solve this problem ?
My application structure like this:
zend_test
PHP Code:
- application
-- controllers
---> HeaderFooterPlugin.php
-- views
--- scripts
--- test
----> index.phtml
---> footer.phtml
---> header.phtml
- html
--> index.php
and the index.php code like this:
PHP Code:
....
require_once '../application/controllers/HeaderFooterPlugin.php';
....
$front_controller->setControllerDirectory("../application/controllers")
->setRouter($router_rewrite)
->registerPlugin(new HeaderFooterPlugin())
->throwExceptions(true);
....
$front_controller->dispatch();
and the HeaderFooterPlugin.php just almost fully copy from the offical site:
PHP Code:
require_once 'Zend/Controller/Front.php';
require_once 'Zend/Controller/Plugin/Abstract.php';
class HeaderFooterPlugin extends Zend_Controller_Plugin_Abstract {
public function preDispatch($request) {
$response = $this->getResponse();
$view = new Zend_View();
$view->setBasePath('../views/scripts');
$response->prepend('header', $view->render('header.phtml'));
}
public function postDispatch($request) {
...
}
}
Thanks ~