Jump to content

display category, category link and category thumbnail in homefeatured module


Recommended Posts

Hi there.

I'm changing homefeatured module to display category, category link and category thumbnail before product list.

I've manage to achieve this code in product-list.tpl:

 

{foreach from=$products item=product name=products}
            {if isset($product.id_category_default)}
                <p>Najchętniej wybierane</p>
                <h3>{assign var='catname' value=Category::getCategoryInformations(array($product.id_category_default))}
                <span>{$catname[$product.id_category_default].name}</span></h3>                
                <a href="{$link->getCategoryLink({$product.id_category_default})}"><span class="more-icon">{l s='More'}</span></a>                
            {/if}
{/foreach}

 

It works but I get all categories and list for everyone product as foreach shouldn't be used here. What I want is code to take category, link and category thumbnails for category hooked in back office or category of first item.

Link to comment
Share on other sites

I've made it :)

 

{foreach from=$products item=product name=products}
            {if isset($product.id_category_default)}
                <img class="cat-image-link" src="{$link->getCatImageLink($product.category, $product.id_category_default, 'medium_default')}" />                   
                    <h3>{assign var='catname' value=Category::getCategoryInformations(array($product.id_category_default))}
                    <span>{$catname[$product.id_category_default].name}</span></h3>                
                    <a class="button ajax_add_to_cart_button btn btn-default" href="{$link->getCategoryLink({$product.id_category_default})}"><span class="more-icon">{l s='More'}</span></a>                
            {/if}
            {break}            
        {/foreach}

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