Hi there, I want to load jquery-admin.js while on admin module, and jquery-site.js while on the front end ( site ) module.
I also initiated the request from the bootstrap so that I can get Zend_Controller_Request_Http data before the bootstrap dispatches( I am afraid that it doesn't work ) like this:
public function _initRequest()
{
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$front->setRequest(new Zend_Controller_Request_Http());
return $front->getRequest();
}
And from _initView function, I am loading JavaScript and CSS files as follows: protected function _initView(){
$view = new Zend_View();
$front = Zend_Controller_Front::getInstance();
$view->doctype('XHTML1_STRICT');//initialization of the doctype
$params = $front->getParams();
/**
trying out
$module = $front->getRequest()->getModuleName();
fails since Zend_Controller_Request_Http data have not been loaded yet
*/
if ( in_array ( 'admin', $params ) ) {
$view->headScript()->appendFile('/js/jquery-admin.js');
}else{
$view->headScript()->appendFile('/js/jquery-site.js');
}
return $view;
}
I dont want to load JS files from admin/layout.phtml or site/layout.phtml as this helps me to stick on DRY principles. I am running short of ideas, and I really need your help. any comment/suggestion will be highly appreciated. thanks very much.