Jump to content

don't add css and js in frontController in prestashop 1.4x


Recommended Posts

hi

i create frontController in my module and this is work

but in setMedia i add css and js file but not loaded in head

i check by firebug i'ts not exists

my code :

class myController extends FrontcontrollerCore
{
.
.
.
.
.
public function setMedia()
   {
	   parent::setMedia();
    Tools::addJS(dirname(__FILE__).'/js/testfile.js');
    Tools::addCSS(dirname(__FILE__).'/tests.css');


   }
}

please help

csss and js file is exsits in my module

thank you

Link to comment
Share on other sites

any body don't know about that?

 

 

ok i try to solve this problem myself i waste couple hours and i can solve this

i read the Tools::addCss

and i realized that i have to include path from base url like PS_BASE_URL_ or _MODULE_DIR_

the code of setmedia function should be like this:

public function setMedia()
{
			   parent::setMedia();
		Tools::addJS(_MODULE_DIR_.'moduleName/js/testfile.js');
		Tools::addCSS(_MODULE_DIR_.'moduleName/tests.css');


}

we can use _PS_BASE_URL_ or other url path defines just we can't use

dirname(__FILE__)

thank you

Edited by sharif854 (see edit history)
  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...