Jump to content

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 :)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

By adding $params, it works. However in that guide this is not explained. it is better to modify the guide in the future :)

Share this post


Link to post
Share on other sites

thanks for information that it works for you :-)

 

i can go ahead and mark this thread as solved

 

regards

Share this post


Link to post
Share on other sites

Hi Everybody!

I just debug the $params var, and just for documentation purposes:

 

What exactly stores this variable?

Thanks in advance!

Share this post


Link to post
Share on other sites

I'd like to precise that if the css file exists but is empty, it is NOT included as well. hope it helps someone :)

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More