Jump to content

How to display a list of sub-categories (from only one category)


noesac

Recommended Posts

I have the following piece of code which displays all Parent categories:


     {foreach from=$blockCategTree.children item=child name=blockCategTree}
         {if $smarty.foreach.blockCategTree.last}
           {include file=$branche_tpl_path node=$child last='true'}
       {else}
           {include file=$branche_tpl_path node=$child}
       {/if}
     {/foreach}



I want to display all Subcategories, but only for one specific Category

Anyone know how I can do this?

Link to comment
Share on other sites

To display a list of sub-categories (from only one category)
replace following code of block in file modules --> blockcategories-->blockcategories.tpl

{foreach from=$blockCategTree.children item=child name=blockCategTree}
         {if $smarty.foreach.blockCategTree.last}
           {include file=$branche_tpl_path node=$child last='true'}
       {else}
           {include file=$branche_tpl_path node=$child}
       {/if}
     {/foreach} 




replace with the code

{foreach from=$blockCategTree.children item=child name=blockCategTree}
  {if $child.name==iPods} // or you can check by id {if $child.id==2}
//{if $child.name=='categoriename'} // or you can check by id {if $child.id==categorieId}
       {if $smarty.foreach.blockCategTree.last}
           {include file="$branche_tpl_path" node=$child last='true'}
       {else}
               {include file="$branche_tpl_path" node=$child}
       {/if}
   {/if}
{/foreach}

Link to comment
Share on other sites

It didn't work unfortunately, when I remove lines 2 and 8, it just shows all the parent level categories, are you sure that's right?


     {foreach from=$blockCategTree.children item=child name=blockCategTree}
       {if $child.id==18}
           {if $smarty.foreach.blockCategTree.last}
               {include file=$branche_tpl_path node=$child last='true'}
           {else}
               {include file=$branche_tpl_path node=$child}
              {/if}
       {/if}
     {/foreach}

Link to comment
Share on other sites

  • 4 weeks later...

{if $child.name=='categoriename'} // or you can check by id {if $child.id==categorieId}

 

replace categoriename with your desired catergory Ex. ipod then complete syntax will be look lik

 

{if $child.name=='ipos'}

 

 

2- If you want to display by category

Ex if ipod category id=2

then you syntax should like

  {if $child.id==2}

 

tested on prestashop v1.4+

Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...
  • 2 years later...

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