Jump to content

Create link for product image with category image


Recommended Posts

I posted this on a forum and i got a response but it did not work for me ... 

What I'm trying to do is to get the category image to show instead of the product image. What I have done for the category product list which works is this.

This only works if you are looking at all the products in a category but not if you search for a product?

<a href="{$product.link|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}">
<img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'large_default')}" style="width:140px!important;" alt="{$product.legend|escape:'htmlall':'UTF-8'}" />
</a>

I was wondering how do I get this to work all of the site? How do I make it pull the category images? Like it is above but for the whole site?

 

This was his response and i dont know what it means... 

 

You can do a multiple actions to create such an image, first of all you call for $category class in product page, so $category is not defined.

best solution is to create a assigment for $category in productController in override directory.

class ProductController extends ProductControllerCore
{
public function initContent()
{
parent::initContent();
$category = new Category($this->product->id_category_default);
$this->context->smarty->assign('category', $category);
}
}

i would like to know what he ment by this becuase i tried it and it did not work ? please help me i need this and i will be done with my project 

 
Link to comment
Share on other sites

×
×
  • Create New...