4

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.

2 Answers 2

11

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

2

I found the solution using partial guesswork with the application.ini file. Here are the two Entries you can change in Zend Framework 1.11.12.

resources.layout.layoutPath = "/path/to/layouts/"
resources.view.scriptPath = "/path/to/scripts/"

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.