Does a simple file include a problem in Zend?

I created a zend project on ubuntu, which is located in the / var / www / student / directory .

Now I have a head.phtml file in this place:

/student/application/views/scripts/index/head.phtml

When I try to include the head.phtml file in

/student/application/modules/test/views/scripts/all/index.phtml

Like this:

echo $this->partial('index/head.phtml');

This gives me the following error:

Message: script 'index/head.phtml' not found in path (/var/www/student/application/modules/notification/views/scripts/) 

Including files is always a difficult task for me. How to fix it. I have to include this file in many modules, and then, what is the permanent solution for this, I must not guess the path

thank

+3
source share
3 answers

script. - (, head, footer, metas...).

setupView bootstrap, , :

protected function _initView()
{
    $view = new Zend_View();

    // setup your view with jquery and other stuffs... 
    // [ ... ]

    // add the view directory to the stack of scripts paths
    $view->addScriptPath(APPLICATION_PATH . '/views/scripts/');
}
+2
<? $this->setScriptPath('/student/application/views/scriptss'); ?>
<?= $this->partial('index/head.phtml') ?>
0

I added the following line to the Controller function init().

public function init() {
    $this->view->addScriptPath( APPLICATION_PATH . '/views/scripts/' );
}

Add the head.phtml file as follows:

echo $this->partial('index/head.phtml');

File added successfully.

0
source

All Articles