Jump to content

[SOLVED]Link different css file for another language


Recommended Posts

Hi 

 

I would really need a hand here. I've been working on a topmenu with images instead of text. All good but preferably i would like to add different background image for both languages that are present in my store.

 

Is there a way to link one css for each language? Or keep one css standard and just add one css file when the default language changes?

 

 

Edited by sw1ft25 (see edit history)
Link to comment
Share on other sites

hello

you can achieve it but only with module modification, there is no other way at the moment.

in this case, in module file, in hookdisplayTop function you have to change:

$this->context->controller->addCSS($this->_path.'css/superfish-modified.css');

to:

if ((int)Context::getContext()->language->id==1){
   $this->context->controller->addCSS($this->_path.'css/lagnuage1-superfish-modified.css');
} elseif ((int)Context::getContext()->language->id==2){
   $this->context->controller->addCSS($this->_path.'css/lagnuage2-superfish-modified.css');
} elseif ((int)Context::getContext()->language->id==3){
   $this->context->controller->addCSS($this->_path.'css/lagnuage3-superfish-modified.css');
} elseif ((int)Context::getContext()->language->id==X){
   $this->context->controller->addCSS($this->_path.'css/lagnuageX-superfish-modified.css');
}

you can add as many if conditions as you want :-)

  • Like 1
Link to comment
Share on other sites

Thank you for this fast response! But let me make it clear for me:

 

I have to edit blocktopmenu.php from root/modules/blocktopmenu 

 

I added these lines:

$this->context->controller->addJS($this->_path.'js/hoverIntent.js');
		$this->context->controller->addJS($this->_path.'js/superfish-modified.js');
		$this->context->controller->addJS($this->_path.'js/blocktopmenu.js');
		$this->context->controller->addCSS($this->_path.'css/blocktopmenu.css');
		
		if ((int)Context::getContext()->language->id==1){
   		$this->context->controller->addCSS($this->_path.'css/superfish-modified.css');
} elseif ((int)Context::getContext()->language->id==2){
   		$this->context->controller->addCSS($this->_path.'css/en.css');

And all i gott is a blank page.

 

My modified css file is in root/themes/default-bootstrap/css/modules/blocktopmenu/css

 

I'm a bit confused why I got the blank page display. Thanks

Link to comment
Share on other sites

public function hookDisplayTop($param)
	{
		$this->user_groups =  ($this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')));
		$this->page_name = Dispatcher::getInstance()->getController();
		if (!$this->isCached('blocktopmenu.tpl', $this->getCacheId()))
		{
			if (Tools::isEmpty($this->_menu))
				$this->makeMenu();
			$this->smarty->assign('MENU_SEARCH', Configuration::get('MOD_BLOCKTOPMENU_SEARCH'));
			$this->smarty->assign('MENU', $this->_menu);
			$this->smarty->assign('this_path', $this->_path);
		}

		$this->context->controller->addJS($this->_path.'js/hoverIntent.js');
		$this->context->controller->addJS($this->_path.'js/superfish-modified.js');
		$this->context->controller->addJS($this->_path.'js/blocktopmenu.js');
		$this->context->controller->addCSS($this->_path.'css/blocktopmenu.css');
		
		if ((int)Context::getContext()->language->id==1){
   		$this->context->controller->addCSS($this->_path.'css/superfish-modified.css');
} elseif ((int)Context::getContext()->language->id==2){
   		$this->context->controller->addCSS($this->_path.'css/en.css');



		$html = $this->display(__FILE__, 'blocktopmenu.tpl', $this->getCacheId());
		return $html;
	}
	

Like this

Link to comment
Share on other sites

×
×
  • Create New...