How to use template from another context, i.e. get frontend template from backend?
It's need for preview function in backend. I want to avoid duplicating templates.
// in some backend module action
$this->setTemplat开发者_高级运维e(sfConfig::get('sf_apps_dir').'/frontend/modules/module/templates/tpl');
because context is backend, how about partials in tpl, routes and so forth?
Actually you can use templates from other modules and even other apps.
The documented way to use a template from another module is
$this->setTemplate('templateName, 'moduleName');
There is no documented way to use a template from another application, but by looking at the source code for symfony (1.x, anyway), you find that you can set the template from another application by:
$this->setTemplate('templateName','../../appName/modules/moduleName');
When you call $this->setTemplate($name), $name refers to the name of a template within the same module. You cannot set templates from other modules using this method.
精彩评论