Share » Forums » Setup & design » Navigation menu. How does site menu...

Navigation menu. How does site menu look?

Navigation menu. How does site menu look?

Thursday 06 May 2004 4:19:36 am - 4 replies

Modified on Thursday 06 May 2004 10:41:06 am by Yauheni Lapanau

Author Message

Alex Jones

Thursday 06 May 2004 7:10:10 am

Well, I'm not positive that I understand your question, but if you want an example of the code needed to display anavigation menu like the one posted above, here is some code that I use for my site nav which is pretty close:

{let depth=3 
     docs=treemenu( $module_result.path, $module_result.node_id, array('folder','info_page','article'), 0, 6 ) 
     thisnode=fetch('content','node',hash('node_id',$module_result.node_id)) }
<ul class="Menu">

{section var=menu loop=$:docs last-value}
  {section show=and($menu.last.level|gt($menu.level),$menu.number|gt(1))}
    </ul>
    </li>
  {/section}
  <li>
  {section show=and($menu.last.level|lt($menu.level),$menu.number|gt(1))}
    <ul>
      <li>{/section}
     {set depth=$menu.level}<a href={$menu.url_alias|ezurl} {section show=eq($thisnode.name,$menu.text)}class="Selected"{/section}>{section show=eq($thisnode.name,$menu.text)}<strong>&raquo;</strong> {/section}{$menu.text|shorten(30)}</a></li>
   {/section}
   
  </ul>
  {section show=$depth|gt(1) loop=$depth|sub(1)}
  </li>
</ul>
{/section}
</li>
</ul>
{/let}

I use <i>{section show=eq($thisnode.name,$menu.text)}</i> to set a class of "Selected" to style the link to the current page via CSS. You can use the same detect to hide the link altogether if you wish.

Does this help?

Alex

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

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

Yauheni Lapanau

Thursday 06 May 2004 10:09:49 am

Thaks, for the code. I want example of the code with requirements:
Don't show link to the curent node. Have tree like structure.
May you explain the main moments of the code?
But I don't understand, what does it mean "You can use the same detect to hide the link altogether if you wish."

Alex Jones

Thursday 06 May 2004 11:24:56 am

Sure thing. Here is the code with comments inserted. I have modified this code so it does not print out the link of the page that the user is currently viewing.

{*
Create the tree menu and tell it which classes of objects that it should display. This version will only show objects that are either a folder, an info page or an article. 
The '0' indicates that we want the menu to start at the root folder - change this to a different number to set it to start at a lower depth. The '6' indicates that the menu should
not show more than six levels deep. Again, this can be modified to show as many levels as you want.  

Also, set up the variable 'thisnode' which we will use to determine which node from the treemenu matches the currently viewed page.
*}
{let docs=treemenu( $module_result.path, $module_result.node_id, array('folder','info_page','article'), 0, 6 ) 
     thisnode=fetch('content','node',hash('node_id',$module_result.node_id)) }
<ul class="Menu">

{section var=menu loop=$:docs last-value} {* Loop through the results of $docs to write out the menu items *}
  {section show=and($menu.last.level|gt($menu.level),$menu.number|gt(1))} {* Check if the current menu item is the last one in its level. If it is, close the list tags *}
    </ul>
    </li>
  {/section}
  <li>
  {section show=and($menu.last.level|lt($menu.level),$menu.number|gt(1))}  {* Check if this item is the first one at its level. If it is, open the list tags. *}
    <ul>
      <li>{/section}
	  {* Print the menu item *}
     {set depth=$menu.level} {* Set the variable $depth to the current depth of the menu item *}
	 {section show=ne($thisnode.name,$menu.text)} {* If this menu item matches the current page, do not print the link, just print the name of the page *}
	   {$menu.text|shorten(30)}
	 {section-else} {* This menu item does not match the currently viewed page, so print out the link *}
	   <a href={$menu.url_alias|ezurl}>{$menu.text|shorten(30)}</a>
	 {/section} 
	 </li>
   {/section}
   
  </ul>
  {section show=$depth|gt(1) loop=$depth|sub(1)} {* If this is the absolute last item for the entire menu, print the final closing list tags *}
  </li>
</ul>
{/section}
</li>
</ul>
{/let}

Treemenu documentation: http://ez.no/ez_publish/documentation/reference/template_operators/miscellaneous/treemenu

Alex

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

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

Yauheni Lapanau

Thursday 06 May 2004 1:39:33 pm

Thanks you for comments and good code.
I have change code in one place.

 

{section show=ne($thisnode.name,$menu.text)} 
   <a href={$menu.url_alias|ezurl}> {$menu.text|shorten(30)}</a>
 {section-else} 
   {$menu.text|shorten(30)}
 {/section}



I found some additional information about tree menu
http://ez.no/community/contributions/template_plugins/extension_treemenu_pubsvn

There are interesting parameter - Displayes Children of Nodes that are not highlighted.

and
http://ez.no/community/contributions/template_plugins/dynamic_menu_operator

I don't understand how can I use this extention?

What is the glossary extantion?

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu