cingkonext Posted June 16, 2014 Share Posted June 16, 2014 (edited) I made a hook header function as below: public function hookHeader ($ params) { if ($ this-> isModuleAvailable ()) return; $ This-> context-> controller-> addCSS (($ this-> _path). 'Mystyle.css', 'all'); $ This-> context-> controller-> addJS (($ this-> _path). 'Myjavascript.js'); } If the variable in the function does not work (like the mobile version), how to include these two files on my smarty page (Mypage.tpl)?so far I've made it like this (in file "Mypage.tpl"): {If ($ mobile) == '1 '} <script type="text/javascript" src="{$new_base_dir}Myjavascript.js"> </ script> {/ If} This works well to call the javascript functions. but how to include files mystyle.css? Edited June 16, 2014 by cingkonext (see edit history) Link to comment Share on other sites More sharing options...
cingkonext Posted June 16, 2014 Author Share Posted June 16, 2014 My Hook footer: public function hookFooter($params) { require_once(_PS_TOOL_DIR_.'mobile_Detect/Mobile_Detect.php'); $this->mobile_detect = new Mobile_Detect(); $mobile = '0'; if ($this->mobile_detect->isMobile()) { $mobile = '1'; } $protocol = (Configuration::get('PS_SSL_ENABLED') || (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; $endURL = __PS_BASE_URI__.'modules/mymodule/'; if (method_exists('Tools', 'getShopDomainSsl')) $moduleURL = $protocol.Tools::getShopDomainSsl().$endURL; else $moduleURL = $protocol.$_SERVER['HTTP_HOST'].$endURL; $this->smarty->assign(array( 'mobile' => $mobile, 'new_base_dir' => $moduleURL, )); return $this->smarty->fetch($this->template_directory.'Mypage.tpl'); } Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted June 16, 2014 Share Posted June 16, 2014 Hi, I also use this function for add CSS files in my module: public function hookDisplayHeader() { $this->context->controller->addCSS(($this->_path) . 'css/styles.css', 'all'); } Regards Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now