Jump to content

Created a simple Module cannot hook it to my header?


seancss

Recommended Posts

Hi noobie here,

Can't figure this one out, i have created a simple navigation module, it is just a list of linked buttons I want to place at the "top" of every page,

 

my default placement is as follows:

 

 

 

function install()

{

if (!parent::install())

return false;

if (!$this->registerHook('leftColumn'))

return false;

 

return true;

}

 

 

I can see my module now squashed into the leftColumn, i now went to move it to where the currency

changer is in the header, from reading i'm aware that header location places code between <head> tags?, so I went and copied the code from the Currency changer module as follows.

 

return (parent::install() AND $this->registerHook('top') AND $this->registerHook('header'));

 

I am unsure why both header and top are selected here? but this still does not show my module in the header, my module is set to float right and I made it huge with red background just to see would it show but no luck, but it shows if I have leftColumn as stated at the start?

 

Any help would be great loving Presta already

Link to comment
Share on other sites

Seems I have hookHeader not hookTop still no display it says the currency changer I have is placed in the technical name "header", I decided to build a Module as I thought it was best practice but from lack of response I don't know how to figure this one out and may resort to hardcoding it, i'm using the original Prestashop template thanks cartExpert btw.

Link to comment
Share on other sites

Hello!

 

Without seeing the code it's hard to answer the question or solve your problem.

 

 

Ye I know what you mean,

 

if this is any help here is the currency block code that shows in the header div at the top of the page, I tried to use the position this allocated without anylook as stated earlyr maybe im missing something, going to go at it again tomarrow

 

 

class BlockCurrencies extends Module

{

public function __construct()

{

$this->name = 'blockcurrencies';

$this->tab = 'front_office_features';

$this->version = 0.1;

$this->author = 'PrestaShop';

$this->need_instance = 0;

 

parent::__construct();

 

$this->displayName = $this->l('Currency block');

$this->description = $this->l('Adds a block for selecting a currency.');

}

 

public function install()

{

return (parent::install() AND $this->registerHook('top') AND $this->registerHook('header'));

}

 

/**

* Returns module content for header

*

* @param array $params Parameters

* @return string Content

*/

public function hookTop($params)

{

if (Configuration::get('PS_CATALOG_MODE'))

return ;

 

global $smarty;

$currencies = Currency::getCurrencies();

if (!sizeof($currencies))

return '';

$smarty->assign('currencies', $currencies);

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

}

 

public function hookHeader($params)

{

if (Configuration::get('PS_CATALOG_MODE'))

return ;

Tools::addCSS(($this->_path).'blockcurrencies.css', 'all');

}

}

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