0
votes

I'd like to call a .phtml file I have in /application/views/scripts in my view helper located in /library/Foo/View/Helper. Zend shows an error as partial is not a defined method within Zend_View_Helper.

Is what I am trying to do possible? On Zend Framework v1.12.

Syntax would look something like below:

View Helper:

class Foo_View_Helper_NavPopup extends Zend_View_Helper_Abstract
{
    public function navPopup() {

        $popup = $this->partial("popup.phtml");
        return $popup;
    }
}

View Script (popup.phtml):

<div id="container">html things and stuff and such and so forth..</div>
1
Have you tried? $this->view->partial("popup.phtml"); - Bruno Calza
@BrunoCalza that got me partially there, but it appears Zend is searching for the script in the namespace of the page I'm currently on (upon refresh, Zend error reads "script 'popup.phtml' not found in path ..."). This script and helper are to be used in the header section of the page which does not change throughout navigation. - phamousphil
what folded is 'popup.phtml'? Try to put it inside views/scripts - Bruno Calza
popup.phtml is currently in /application/views/scripts. - phamousphil
Now I see that you put the location of the files in the question description. Try to put the helper inside /application/views/helpers - Bruno Calza

1 Answers

1
votes

The main source of the problem here was a quirky namespacing issue with my codebase, specifically because I am working with the header of the page and not a specific module within the application itself.

By using $this->view->addScriptPath(APPLICATION_PATH . "/views/scripts/"); I gave the view an explicit direction to the path to find the script. This fixed the problem.