Josh Pennington
Josh Pennington

Reputation: 6408

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.

Upvotes: 4

Views: 6632

Answers (2)

Ryan Daniels
Ryan Daniels

Reputation: 301

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/"

Upvotes: 2

simonrjones
simonrjones

Reputation: 1182

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

Upvotes: 11

Related Questions