Jump to content

CSS not displaying in myModule tutorial


Recommended Posts

I simply wanted to display the mymodule tutorial in my nav bar in the default theme. It displays there, but the CSS is not applied.

<?php

if (!defined('_PS_VERSION_'))
  exit;

 
class MyModule extends Module
{
  public function __construct()
  {
    $this->name = 'mymodule';
    $this->tab = 'front_office_features';
    $this->version = '1.0';
    $this->author = 'Firstname Lastname';
    $this->need_instance = 0;
    $this->ps_versions_compliancy = array('min' => '1.6', 'max' => '1.6'); 
    $this->dependencies = array('blockcart');

    parent::__construct();

    $this->displayName = $this->l('My module');
    $this->description = $this->l('Description of my module.');

    $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

    if (!Configuration::get('MYMODULE_NAME'))       
      $this->warning = $this->l('No name provided');
  }
  
	public function install()
	{
		if (Shop::isFeatureActive())
			Shop::setContext(Shop::CONTEXT_ALL);
	
		return (parent::install() && $this->registerHook('displayTop') && $this->registerHook('displayNav') && $this->registerHook('displayHeader'));
	}
	
	public function uninstall()
	{
	  if (!parent::uninstall() || !Configuration::deleteByName('MYMODULE_NAME'))
			return false;
	  return true;
	}
	

	public function hookDisplayTop($params)
	{
		if (!$this->active)
			return;

		$this->context->smarty->assign(
		  array(
			  'my_module_name' => Configuration::get('MYMODULE_NAME'),
			  'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display')
		  )
	  );
	  
	  return $this->display(__FILE__, 'mymodule.tpl');
	}

	public function hookDisplayHeader($params)
	{
		$this->context->controller->addCSS($this->_path.'css/mymodule.css', 'all');
	}

	public function hookDisplayNav($params)
	{
		return $this->display(__FILE__, 'mymodule.tpl');
	}
}
?>


	


TPL file

<!-- Block mymodule -->
<div id="mymodule_block_left" class="block">
  <div class="block_content">
    <p>Hello, 
       {if isset($my_module_name) && $my_module_name}
           {$my_module_name}
       {else}
           World
       {/if}
       !        
    </p>    
    <ul>
      <li><a href="{$my_module_link}" title="Click this link">Click me!</a></li>
    </ul>
  </div>
</div>
<!-- /Block mymodule -->

css:

div#mymodule_block_left p { 
  font-size: 150%;
  font-style:italic;
  color: Red;
}

any ideas why the css is not displaying? thank you for your help.

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

perhaps you run store with activated option: CCC for CSS ?

you can check it under adv. parameters > performance tab

make sure that this option is disabled (only when you dealing with shop theme, modules etc.)

 

it's necessary to recompile files

Link to comment
Share on other sites

  • 8 months later...

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