how to setup a menu with only specific folders

Author Message

elaheh tabbakh maher

Saturday 07 March 2009 5:25:09 pm

Hi,
Can someone tell me how to setup a menu from only specific folders, I have to show a menu in a template with only ;
Folder 1
Folder4
Folder5

Thank you,

Jean-Yves Zinsou

Sunday 08 March 2009 5:21:42 am

Hi,
you could add some checking in the loop displaying the folders ...

{def folder1_id=123,
folder2_id= 134, 
folder3_id=233}
{def $folders_to _display=array($folder1_id, $folder2_id, $folder3_id)}
{foreach $children as $child}
{if $folders_to_display|contains($child)}
{*display the entry*}
{/if}

{/foreach}

Code not tested, but that is the idea...

HTH

jey

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

elaheh tabbakh maher

Sunday 08 March 2009 10:35:18 am

Hi,
I am using the double_top.tpl with topdrop extension and the code for showing the first level is as follow and I am not sure where in that code should be changed with your suggestion:
------------------------------------

{def $base=fetch( 'content', 'node', hash( 'node_id', 2 ) )} {* FIRST LEVEL *} {def $i=0} {section loop=fetch(content,list,hash(parent_node_id,$top_cat, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))} {let child_check=fetch(content,list,hash(parent_node_id,$:item.node_id, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))} {set $i=inc( $i )}
<li><a class="{concat('menu_',$i)}" href={$:item.url_alias|ezurl}>{$:item.name}

{section show=$child_check|count|gt(0)}

{* SECOND LEVEL *}
<!--[if IE 7]><!--></a><!--<![endif]-->
------------------------------------------------------------------------------------------------

Thank you

Jean-Yves Zinsou

Sunday 08 March 2009 10:58:25 am

I am not very familiar with the section loop but this is where i would put it...


{def $base=fetch( 'content', 'node', hash( 'node_id', 2 ) )} 
{* FIRST LEVEL *} 
{def $i=0}
 {section loop=fetch(content,list,hash(parent_node_id,$top_cat, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))} 
{*-----------your checking here start-------------*}
{if $folders_to_display|contains($:item.node_id)}

{let child_check=fetch(content,list,hash(parent_node_id,$:item.node_id, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))} {set $i=inc( $i )}

<li><a class="{concat('menu_',$i)}" href={$:item.url_alias|ezurl}>{$:item.name}

{section show=$child_check|count|gt(0)}

{* SECOND LEVEL *}
<!--[if IE 7]><!--></a><!--<![endif]-->

{/section}
{*-----------your checking here end------------*}
{/end if}
{/section}

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

elaheh tabbakh maher

Friday 13 March 2009 4:34:50 am

Hi,
Thank you for your help, but this code does not work, it puts a strange menu out of where it should appear and it does not appear and does not work with double_top.tpl.
Regards

Jean-Yves Zinsou

Friday 13 March 2009 5:01:40 am

Hi , it is because it was not clear enough.

The code you gave is incomplete ,


{def $base=fetch( 'content', 'node', hash( 'node_id', 2 ) )} {* FIRST LEVEL *} {def $i=0} {section loop=fetch(content,list,hash(parent_node_id,$top_cat, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))} {let child_check=fetch(content,list,hash(parent_node_id,$:item.node_id, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))} {set $i=inc( $i )}
<li><a class="{concat('menu_',$i)}" href={$:item.url_alias|ezurl}>{$:item.name}

{section show=$child_check|count|gt(0)}

{* SECOND LEVEL *}
<!--[if IE 7]><!--></a><!--<![endif]-->


{*code missing here there should be a /section somewhere*}
 

in fact you have to replace the code section you gave with



{def $base=fetch( 'content', 'node', hash( 'node_id', 2 ) )} 

{* FIRST LEVEL *} 

{def $i=0}


 {section loop=fetch(content,list,hash(parent_node_id,$top_cat, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))} 

{*-----------your checking here start-------------*}


{if $folders_to_display|contains($:item.node_id)}
{let child_check=fetch(content,list,hash(parent_node_id,$:item.node_id, class_filter_type, "include", class_filter_array, array(1, 16, 17, 19, 20, 23, 38, 39),sort_by,$base.sort_array))} {set $i=inc( $i )}
 
<li><a class="{concat('menu_',$i)}" href={$:item.url_alias|ezurl}>{$:item.name}
{section show=$child_check|count|gt(0)}

{* SECOND LEVEL *}
<!--[if IE 7]><!--></a><!--<![endif]-->

Then find the next {/section} tag
and add

{/end if}

after it

Sorry, things that may be obvious for one, may not be to others.
My apologies.

Hope this really helps this time ;-)
Jey

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.