Search code examples
zend-frameworktemplateszend-view

Zend view script path setup


Here is the code I have:

$this->getView()->setScriptPath($templatePath);
$this->_helper->viewRenderer($page);

This code is handled in the Core_PageController view action. The problem I have is now the view object looks for my script files in $templatePath/page since page is the controller. What I'd like is for the view object to look in just the $templatePath directory path (without the page directory);

Thanks for the help!


Solution

  • You can instruct the ViewRenderer to not use the controller name as part of the view script path.

    To do that, try:

    $this->_helper
         ->viewRenderer
         ->setNoController(true); // do not use controller name as part of the view path
    

    setNoController($flag = true) can be used to tell render() not to look for the action script in a subdirectory named after the controller (which is the default behaviour). getNoController() retrieves the current value.

    More info on the ViewRenderer helper.