Jump to content

Get category image


Recommended Posts

Hi,

I want to display an image for each category in the menu (different images for different categories). I can't find a module that does this so I'm trying to solve this on my own.

I'm trying to place an image link in categoriesbar module/category-bar-level.tpl that will pick up the category image. I've succeeded in getting the path to the image folder ( {$img_cat_dir} ) but how do I pick up the category image? I've tried yo use {$category->id_image} but it doesn't work...

Thankful for a solution! :)

Link to comment
Share on other sites

  • 1 year later...

Hi,

What version do you use in prestashop?

I am using prestashop v 1.4.1. I display all categories on home page with their images. I success.
This is the site that i built

http://sourcing-in-vietnam.com

And here my solution

In modules/blockcategories/category-tree-branch.tpl, change this code

getCatImageLink($category->link_rewrite, $node.id, 'category')}"[/b] alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />

Hope this will help you.

Link to comment
Share on other sites

  • 6 months later...

Hi ashian,

 

I changed like what u said. It wont give image.

 

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

 

any one help regarding this?

Link to comment
Share on other sites

  • 2 years later...
{assign var="cat_img" value="$tpl_dir../../img/c/{$node.id}-categories_home.jpg"}
{if file_exists($cat_img)} 
	<img class="replace-2x" src="{$cat_img}" alt="" />
{else}
	<img class="replace-2x" src="/img/c/nl-default-categories_home.jpg" alt="" />
{/if}	

Hope it is clear :) This should work in 1.5 and 1.6

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