开发者

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 开发者_JAVA技巧this location to something that is configurable?

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


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜