gorhgorh Posted December 14, 2011 Share Posted December 14, 2011 hi there, newbee of prestashop and comming for the frontend world, i'm trying to make a theme, and i realised that unlike other shop/cms i cant really add my js/ccs inside the template itself, so i've started to build a module to add some js, mainly for feature detection, and loading polyfills when needed for old browsers to understand front end functlonaity i would need, after a few seach, i realised i should create a module for that, and looked for some tutorials about it, so i made a "modernizr" folder in my module folder, and created this modernizr.php file <?php class Modernizr extends Module { //contructeur du module function __construct() { $this->name = 'Modernizr'; $this->tab = 'front office features'; $this->version = 0.1; $this->displayName = $this->l('Modernizr'); $this->description = $this->l('Active html5 et des super polyfils pour les vieux browsers tout moche'); parent::__construct(); } function install() { if (!parent::install()) return false; if (!$this->registerHook('header')) return false; return true; } public function uninstall() { if (!parent::uninstall()) return false; } //ajout de modernizr public function hookHeader() { Tools::addJS($this->_path.'modernizr.js'); } } ?> i added the js to the modernizr dir, and "installed" my module from the back office, sadly, my js was not correctly added, and i really don't see what i made the wrong way, any help or clue would be appreciated, thanks in advance Link to comment Share on other sites More sharing options...
bellini13 Posted December 21, 2011 Share Posted December 21, 2011 a few things to check 1) make sure the module installed and enabled properly. 2) clear the cache or enable force compile in back office (preferences | performance section) 3) view source the html page and confirm that you do not see modernizr.js in the html 4) confirm the module really is hooking header. go to modules | positions section, select your module and confirm you see header being hooked. Link to comment Share on other sites More sharing options...
gorhgorh Posted December 21, 2011 Author Share Posted December 21, 2011 hi there, 1) it is 2) activated already 3) can't see it at all 4) yep also in addition, if i add a css in this module, it links it properely, so i'm realy lost on this one TBH ... looks like i'll have to 1) forget making clean and 2012'ish pages ... 2) link it in the front controller 3) start using a shop that does not need back en experience to add a simple JS ... Link to comment Share on other sites More sharing options...
bellini13 Posted December 21, 2011 Share Posted December 21, 2011 yea it is very odd, it really should be a very simple thing to accomplish, and your code looks right. to me its a configuration issue somewhere. plenty of the standard prestashop modules do the same thing, so it can't be a bug in the prestashop core code, otherwise none of the .js files would appear in your header. can you confirm you see other .js files in the header? Link to comment Share on other sites More sharing options...
gorhgorh Posted December 22, 2011 Author Share Posted December 22, 2011 yes i do, it must be a really simple thing that i don't see ... i think'll go with the nasty way of extending the frontend controller ... i know this is not best practice but hey ... i need to be able to load js and i spent too much time on this one already, thanks to have looked for my issue anyway . 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