Jump to content

Where Is The "category Thumbnail Image" Located And How To I Reference It?


Recommended Posts

Hi guys,

 

I am wanting to add thumbnail images to the main and subcategories of my Block Category menu that is located in the left hand column of my website.

 

I have found a module that almost does what I want from here but need to modify it to do exactly what I want.

 

Currently, this module uses the existing image (reduced size version) that is attached to the category. I want to use the image that is used in the "Menu Thumbnails" option of the category.

 

Here is a screen shot of what it looks like.

 

http://awesomescreenshot.com/04d5hj47a8

 

I think this is the code that the module uses to get the existing image:

 

{if $psversion > "1.5.0.0"}
<li {if isset($last) && $last == 'true'}class="last"{/if}>
<img src="{$link->getCatImageLink($node.name, $node.id, 'small_default')}" align="absmiddle" width="{$image}" style="margin-left:3px; margin-bottom:3px; float:left">
{* *}
{* The following code is used to get the image and generate the hover text after first stripping out the HTML data from the text *}
{* *}
    <a href="{$node.link|escape:'htmlall':'UTF-8'}" {if isset($currentCategoryId) && $node.id == $currentCategoryId}class="selected"{/if} title="{$node.desc|strip_tags|trim|truncate:255:'...'|escape:'html':'UTF-8'}">{$node.name|escape:'htmlall':'UTF-8'}</a>
    {if $node.children|@count > 0}
        <ul>
        {foreach from=$node.children item=child name=categoryTreeBranch}
            {if $smarty.foreach.categoryTreeBranch.last}
                {include file="$branche_tpl_path" node=$child last='true'}
            {else}
                {include file="$branche_tpl_path" node=$child last='false'}
            {/if}
        {/foreach}
        </ul>
    {/if}
</li>
{/if}

 

Can somebody please tell me how to change this so that it uses the "Menu Thumbnails" image?

 

Thanks for any help you can provide.

 

Regards

Greg

Link to comment
Share on other sites

What do you call "Menu Thumbnails" ?

Image thumbnails per PrestaShop are all the one referenced on Preferences> Images when the checkbox is enabled on image.

The physical image get generated into img/c folder, but you should always access them (for consistent behaviour) using {$link->getCatImageLink($category_link_rewrite,,$id_category,'<the-thumbnail-type-name>')}

Link to comment
Share on other sites

BO -> categories -> choose a category and click on "edit"

On the middle of the page "Menu thumbnails"

 

Nice spotted Eolia, I missed this one.

To reference those "yet-another-wtf-feature" image your need

to HARD CODE using

{$link->getMediaLink($smarty.const._THEME_CAT_DIR_.$id_category.'-thumb.jpg')}{* the category thumb *}
{$link->getMediaLink($smarty.const._THEME_CAT_DIR_.$id_category.'-'.$i._thumb.jpg')}{* the menu thumb *}

On the last one you have to iterate in $i starting at 0 and guess when to stop.

 

Another clever! clever! so well designed/documented feature don't you think?

BTW the snippet above are more principle. You have to {capture} in order to build the proper args to getMediaLink

{capture name=wtf}{$smarty.const._THEME_CAT_DIR_}{$id_category}-thumb.jpg{/capture}
{$link->getMediaLink($smarty.capture.wtf)}
...
Edited by doekia (see edit history)
  • Like 2
Link to comment
Share on other sites

Hi guys.

 

Thanks for the quick and useful replies. I have made the changes and it seems to be working fine.

 

The only thing I now need to do is solve the following issue I have.

 

I have numerous high level parent caregories and many many sub categories.

 

Current, the code that I have modified always looks for a thumbnail image and if it doesn't find an image it will display the "?" to say that it can't find a matching image for that category.

 

What I would like to do is change the code so that if a matching thumbnail doesn't exist then it displays a default image.

 

Could somebody please show me how to change the relevant line of code to do what I want?

 

Thanks again for your help.

 

Regards

Greg

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