Jump to content

Show only categories with an id_parent of 3


justine123

Recommended Posts

Hi,

So I added this code in the product.tpl to show the categories of the product but I only wanted to show the ones with id_parent of 3. I tried using {$cat.id_parent} but there was no display. I'd appreciate any help. Thank you.

here is the code:

<ul class="productcats">
     {foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat}
            <li><a href="{$link->getCategoryLink({$cat.id_category})}" title="{$cat.name}">{$cat.name}</a></li>
      {/foreach}
</ul>

Link to comment
Share on other sites

Or if you want to see only category with id = 3

<ul class="productcats">
     {foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=cat}
            {if $cat.id_category == 3}<li><a href="{$link->getCategoryLink({$cat.id_category})}" title="{$cat.name}">{$cat.name}</a></li>{/if}
            {$cat.id_category}
      {/foreach}
</ul> 

 

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