Jump to content

[solved] addCSS and addJS problem


Recommended Posts

Hi guys,

 

I followed step by step this guide about module developing.

 

Hovewer when i try to do addCss ( or JS ) in the hookDisplayHeader, it doesn't show anything in the <head>.

 

<?php
if( ! defined( '_PS_VERSION_' ) ) exit;
class blockinfo extends Module{
public function __construct(){
 $this->name = 'blockinfo';
 $this->tab = 'front_office_features';
 $this->version = '1.0';
 $this->author = 'Ivano Mercuri';
 $this->need_instance = 0;
 $this->ps_versions_compliancy = array( 'min' => '1.5.4.1' , 'max' => '1.6');

 parent::__construct();

 $this->displayName = $this->l('Informazioni');
 $this->description = $this->l('Inserisce le informazioni nell\'header');

 $this->confirmUninstall = $this->l('Lo vuoi disinstallare?');

 if (!Configuration::get('BLOCKINFO'))	
  $this->warning = $this->l('No name provided');
}

public function install(){
 if ( Shop::isFeatureActive() ){
  Shop::setContext( Shop::CONTEXT_ALL );
 }
 return parent::install() && $this->registerHook( 'leftColumn' ) && $this->registerHook( 'header' ) && Configuration::updateValue( 'BLOCKINFO' , 'my friend' );
}

public function uninstall(){
 return parent::uninstall() && Configuration::deleteByName( 'BLOCKINFO' );
}

public function hookDisplayLeftColumn( $params ){
 $this->context->smarty->assign(
  array(
'blockinfo_name' => Configuration::get( 'BLOCKINFO' ),
'blockinfo_link' => $this->context->link->getModuleLink( 'blockinfo', 'display' )
  )
 );
 return $this->display( __FILE__ , 'blockinfo.tpl');
}

public function hookDisplayRightColumn( $params ){
 return $this->hookDisplayLeftColumn( $params );
}

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

 

Of course, in the active theme the {$HOOK_HEADER} esists. What should I do to make that function works? Thank you :)

Link to comment
Share on other sites

does the file exist? modules/blockinfo/css//blockinfo.css ?

 

can you also try to use the $params variable

 

public function hookDisplayHeader($params){

instead the:

public function hookDisplayHeader(){

 

 

another suggestion:

 

public function hookHeader($params) {

instead the:

public function hookDisplayHeader(){

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 2 years 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...