Jump to content

[SOLVED]Hook Category Logo to header?


Recommended Posts

  • 2 weeks later...

try moving this code from category.tpl:

{if $scenes}
 <!-- Scenes -->
 {include file=$tpl_dir./scenes.tpl scenes=$scenes}
{else}
 <!-- Category image -->
 {if $category->id_image}

id_image}-category.jpg" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" />

 {/if}
{/if}  



after this code in header.tpl:

     <!-- Header -->



         {$HOOK_TOP}



Link to comment
Share on other sites

It's not so easy unfortunately. The $category variable is not available in header.tpl. You'll need to add code like the following to header.php before you can use that variable:

if (isset($_GET['id_category']))
{
   $category = new Category(intval(Tools::getValue('id_category')), intval($cookie->id_lang));
   if (!Validate::isLoadedObject($category))
       $errors[] = Tools::displayError('category does not exist');
   elseif (!$category->checkAccess(intval($cookie->id_customer)))
       $errors[] = Tools::displayError('you do not have access to this category');
   else
   {
       $category->name = Category::hideCategoryPosition($category->name);
       $smarty->assign('category', $category);
   }
}



then you can add the following to header.tpl:

<!-- Category image -->
{if $category->id_image}
   <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" />
{/if}

Link to comment
Share on other sites

  • 2 months later...

For product page you want to get default category for product with something like:

if (isset($_GET['id_product']) AND Validate::isUnsignedId($_GET['id_product'])){
     $idProduct = intval(Tools::getValue('id_product'));
     $product = new Product(intval($idProduct));
     $_GET['id_category'] = $product->id_category_default;
}    

Link to comment
Share on other sites

×
×
  • Create New...