Jump to content

(Solved) Layered Navigation - Displaying Only Available Category Images


Panther.software

Recommended Posts

Hello, i want to display category images on categories filter (seted as a radio) - only those which are available.

 

I've already makes few changes to custom display Layered Navigation module.

It's hooked above product list and displays category images from hard coded path:

	<img class="img-responsive layered_radio" alt="{$value.name}" src="{$link->getCatImageLink($value.name, $id_value, 'medium_default')|escape:'html':'UTF-8'}" />

Is there any chance to retrieve Category as a object? Like on category.tpl:

{if isset($category)}

	{if $category->id AND $category->active}
		
        {if $category->id_image}

            <img class="category-img img-responsive" alt="" src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category_default')|escape:'html':'UTF-8'}" />
        {/if}

See an attachment, thanks in advance post-752070-0-57894500-1448805115_thumb.png

Edited by mlodociany (see edit history)
Link to comment
Share on other sites

Okay i figured it out, it's as simple as php function "file_exist".

 

Code work:

in blocklayered.tpl after "{if $filter.filter_type == 1}" which means it's category type filter:

{if file_exists($cat_img_dir|cat:$id_value|cat:'.jpg')}
													1
													{else}
													0
													{/if} 

1 - true, 0 - false

Remember to put this code in foreach loop to initiate vars.

 

In blocklayered.php above "'col_img_dir' => _PS_COL_IMG_DIR_" add:

                'cat_img_dir' => _PS_CAT_IMG_DIR_,

If you have any question or i am wrong about smth, feel free to reply.

 

Cheers,

Damian from web-zlecenia.pl

Edited by mlodociany (see edit history)
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...