Changing the appearance of the Zend Framework script path module

Now view the scripts located at APPLICATION_PATH . '/modules/my_module/views/scripts/' APPLICATION_PATH . '/modules/my_module/views/scripts/' . I want to place the scripts in '/modules/my_module/views/' (delete the scripts folder). How to achieve this?

application.ini:

 resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.modules[] = resources.view.scriptPath.default = APPLICATION_PATH "/views" 
+4
source share
4 answers

I created a plugin:

 class Application_Model_Controller_Plugin_AddScriptPath extends Zend_Controller_Plugin_Abstract { public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { $view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view; $scriptPath = sprintf('%s/modules/%s/views', APPLICATION_PATH, $request->getModuleName()); if (file_exists($scriptPath)) { $view->addScriptPath($scriptPath); } } } 

and registered it in application.ini :

 resources.frontController.plugins[] = "Application_Model_Controller_Plugin_AddScriptPath" 
+6
source

You can use the setScriptPath(APPLICATION_PATH . '/modules/my_module/views') view setScriptPath(APPLICATION_PATH . '/modules/my_module/views') to replace the script path.

You can also add your script path without overriding the previous one using addScriptPath(APPLICATION_PATH . '/modules/my_module/views') . I use it to organize presentation scripts in different folders.

Hope this helps ...

+6
source

I know this is pretty old, but it might help someone. I had the same problem. I achieved this using

 resources.view.scriptPath = APPLICATION_PATH "/views/" 
0
source

if you want to change the look of the script change for any action
inside the action of your controller add this:

$ this-> view-> addScriptPath (APPLICATION_PATH. 'your / path');
$ This-> Renderscript ('list.phtml');

0
source

Source: https://habr.com/ru/post/1368855/


All Articles