Hi,
The standard extension for template files in Zend Framework is .phtml... I need to change them to .js in one specific module... can anyone help... I'd ideally like to change this a Controller level...
Many thanks...
Hi,
The standard extension for template files in Zend Framework is .phtml... I need to change them to .js in one specific module... can anyone help... I'd ideally like to change this a Controller level...
Many thanks...
In your controller:
public function init() {
$this->getHelper('viewRenderer')->setViewSuffix('js');
}
If you need to apply this to all controllers within a module, you should place this in an abstract controller class used for that module and have each controller in that module inherit from that abstract class.
You could theoretically put this in the module's bootstrap, but it would set the view suffix to 'js'
for every request, even ones that end up not being routed to that specific module. This is because every module's bootstrap is executed for each request, regardless of which module is selected by the dispatcher.
The controller's init()
function, though, will only execute when the module is selected for dispatch.