Jump to content

Need to load products array on header


ReactionCode

Recommended Posts

Hi I'm trying to do a module and when I located on category page I need to load the products array in header.

 

Because the smarty limitations It's not possible to call the var $products on header.tpl.

 

I need the next data to work on my script

 

$product.id, $product.name, $product.price

 

how can i get the var on the header hook? I tried this but don't work

 

module.php

public function hookHeader($params)
{
   if ($page_name == 'category'){
    $products = new Products($_GET['products']);   
    $smarty->assign('products', $products);
  }
  return $this->display(__FILE__, 'views/templates/hook/header.tpl');
}

header.tpl


{if $page_name == 'category'}
      {foreach from=$products item=product}
           my-code {$product.id|escape:'htmlall':'UTF-8'};
           my-code {$product.name|escape:'htmlall':'UTF-8'};
      {/foreach}
{/if}

Thanks

 

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