Jump to content

Can't figure out how to include CSS


Recommended Posts

Hi,

 

Somehow I can't seem to find out how to include my module CSS in my own module.

 

<modulename> = name of the module

 

<modulename>.php contents:

 

public function install()

{

if (parent::install() == false OR !$this->registerHook('home') OR !$this->registerHook('header'))

return false;

return true;

}

 

public function hookHeader($params)

{

Tools::addCSS($this->_path.'/css/<modulename>.css');

}

 

This doesn't work.

 

I have tried some other options as well like:

public function hookHeader($params)

{

Tools::addCSS($this->_path.'css/<modulename>.css');

}

 

public function hookHeader($params)

{

Tools::addCSS($this->_path.'<modulename>/css/<modulename>.css');

}

 

public function hookHeader($params)

{

Tools::addCSS(_PS_MODULE_DIR_.$this->name.'/css/<modulename>.css');

}

 

etc.

 

I also copied my CSS to

/themes/THEMENAME/css/modules/MODULENAME/

 

but this doesn't seem to work either.

 

My CSS file is (to make sure the path is correct) in:

/modules/MODULENAME/

/modules/MODULENAME/css/

/themes/THEMENAME/css/modules/MODULENAME/

 

but still: it isn't included in my module.

 

What am I doing wrong?

Link to comment
Share on other sites

your CSS should be assigned to your TPL file, not in php one. After that you can put css code in your module name css file or in global.css for example: Mymodule.tpl <- css class defined here for example "

 

"

 

Hi Dreamtheme,

First: thanks for your reply.

 

I did include my CSS in my .tpl file:

<div id="" class="infinite_scroll_block""></div>

 

I have created a module CSS file: infinitescroll.css which contains:

.infinite_scroll_block {}

 

I'm trying to add the CSS file to the header section using:

public function hookHeader($params)

{

Tools::addCSS(_PS_MODULE_DIR_.$this->name.'/css/infinitescroll.css');

}

 

or one of the other options mentioned above.

 

However, this isn't working: I can't use the declared CSS styles in my .tpl file. It looks like I'm trying to include the CSS file using a wrong method.

 

Perhaps you have another suggestion?

 

Thanks in advance!

Roy

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...