/ Published in: PHP
This snippet is useful if you want to include partials of another admin generated module into the current one (at runtime). This is necessary to *always* make sure that the partial is available, even after clearing the cache. And this is not always true. E.g. you're clearing automatically or manually the cache and the partial isn't overridden/existent in the other module's templates directory.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// make sure, that the other module was already generated try { // try to initialize a partial view of the offer module $view = new sfPartialView(); // this will throw an exception if the partial doesn't exist $view->initialize($this->getContext(), 'my_module', '_list_td_actions', ''); // call the render() method in order to provoke an exception, so we can generate the module parts // unset the view object to save memory } // catch the exception, fire the admin generator for the offer module, it's neccessary here! catch (Exception $e) { // dividing sf_app_dir and sf_app_module_dir_name is neccessary, // because sfGeneratorConfigHandler will make a regexp match like /[moduleName]/ // to determine the correct module and pass it to sfCrudGenerator // therefore, we cant use the sf_app_module_dir setting, because in windows the regexp will not match sfConfig::get('sf_app_dir'), sfConfig::get('sf_app_module_dir_name'), 'my_module', sfConfig::get('sf_app_module_config_dir_name'), 'generator.yml' ); }