Jump to content

loop over subcategories instead of looping over categories


Recommended Posts

I needed to show just subcategories in the main page, and i take the long road. I mean, i'm using the categories module, but i'm just skipping the categories and showing the subcategories. Now, the problem is that i just can't count them!

Categories can be count, and the wished amount can be set in the control panel. But subcategories are harder to handle. And i don't know much about smarty. Could you please guys give me a tip? This is the code i'm using in category-tree-branch.tpl

{if $node.children|@count == 0}





   {$node.name|escape:html:'UTF-8'}


   {/if}

   {if $node.children|@count > 0}

           {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}

   {/if}

Link to comment
Share on other sites

  • 2 weeks later...

Any clue on this? The above solution is not possible in smarty because it don't allow declaring vars, as far as i know.

EDITED: nevermind. I'm using another module now, that can be controlled easily. I'm referring to the featured products module.

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