Forums / Setup & design / How to add the number of objects of a folder in a tree menu?

How to add the number of objects of a folder in a tree menu?

Author Message

Jorge estévez

Monday 12 April 2004 10:01:54 pm

I have implemented a treemenu for product ramification in an e-commerce site

{* This code is copyright 2038 on mars by polleke and is a stripped version from the book *}
<div>
<h3>{"Productos folder"|i18n("design/shop/layout")}</h3>
<ul>
{let menuLevel2=treemenu($module_result.path,$module_result.node_id,array('product_folder'), 1, 50 )}

{section name=Menu loop=$menuLevel2}
<li style="margin-left: {$:item.level}0px;
{section show=$:item.is_selected}color: red;{/section}">
<a href={$:item.url_alias|ezurl}
{section show=$:item.is_selected} style="color: red;"{/section}>
{$Menu:item.text|shorten(50)}</a>

{*I NEED TO ADD THE NUMBER OF PRODUCTS THAT THE FOLDER HAS*}

</li>
{/section}
{/let}
</ul>
</div>

I would like to add to each folder of the tree menu the number of produtcs that they hold...

please help,

thanks, joe

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Alex Jones

Tuesday 13 April 2004 6:21:52 am

You <i>fetch</i> the amount of objects using <i>list_count</i>. Example:

{let list_count=fetch('content','list_count',hash(parent_node_id,$node.node_id))}
{$list_count}
{/let}

This may need to be tweaked, but should be close to what you need. Just add it in the appropriate spot. The nice thing about using fetch is the flexibility it provides in filtering classes of objects, and even specific attributes of those classes.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>