Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change the location of the view scripts in Zend Framework?

Right now the view scripts for my Zend Framework application are located in the application/views/scripts directory. Is it possible to change this location to something that is configurable?

I am assuming this goes somewhere in the index.php file or my application.ini file.

like image 202
Josh Pennington Avatar asked Dec 17 '22 18:12

Josh Pennington


1 Answers

For convenience ZF automatically sets the view script path to be module/views/scripts/controller/action.phtml

You can add a script path via $view->addScriptPath('/path/to/view/scripts') which adds this new path to the stack of available view script paths. It checks the last one set first, then checks on the one before until it finds a file.

Or you can reset the script path via $view->setScriptPath('/path/to/view/scripts')

If you need to do this for a controller place this in your _init() method. If you need it for your entire application I'd recommend sticking it in your Bootstrap.

I believe it's also possible to place this in application.ini via: resources.view.basePath = "/path/to/views/"

See http://framework.zend.com/manual/en/zend.view.controllers.html

like image 95
simonrjones Avatar answered May 02 '23 18:05

simonrjones