Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-15-2007, 06:07 AM
Junior Member
 
Join Date: Aug 2007
Posts: 10
Unhappy Controller_Plugin's setBasePath + render not work

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 ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 08:10 PM.