Jump to content

Module on right column doesn't have CSS


Intersekt

Recommended Posts

I made a module for my shop for both left and right columns. On left column it works without any problem, in the right column it doesn't work because it doesn't load the css and the js file.

 

This is a piece of code:

 

function hookRightColumn($params)
{
 return $this->hookLeftColumn($params);
}

function hookLeftColumn($params)
{
 global $smarty;

 if (version_compare(_PS_VERSION_,'1.5','>'))
 {
  $this->context->controller->addJS(($this->_path).'blockXXX.js');
  $this->context->controller->addCSS(($this->_path).'blockXXX.css', 'all');
 }
 else
 {
  Tools::addJS(($this->_path).'blockXXX.js');
  Tools::addCSS(($this->_path).'blockXXX.css', 'all');
 }

<etc>

return $this->display(__FILE__, 'blockXXX.tpl');

}

 

What's the problem?

Link to comment
Share on other sites

Hi!

 

addJS and addCSS don't work in right columns (do not ask me why!)

 

The solution is simple:

 

 

function hookHeader($params) {

 if (version_compare(_PS_VERSION_,'1.5','>'))
 {
  $this->context->controller->addJS(($this->_path).'blockXXX.js');
  $this->context->controller->addCSS(($this->_path).'blockXXX.css', 'all');
 }
 else
 {
  Tools::addJS(($this->_path).'blockXXX.js');
  Tools::addCSS(($this->_path).'blockXXX.css', 'all');  
}

function hookRightColumn($params) {  
 return $this->hookLeftColumn($params);
}

function hookLeftColumn($params) {  
 global $smarty;	

 <etc>

 return $this->display(__FILE__, 'blockXXX.tpl'); }</etc>
}

 

And link your module to the Header...

 

Edited by SoluNeXT (see edit history)
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...