Showing third menu level

Author Message

DeAndre Johnson

Sunday 27 September 2009 10:40:49 pm

I have a custom and complex dropdown menu that shows at once the second level, third level, and featured items in the dropdown. The dropdown is broken down into sections like "base (second level), center (third level), left (featured). What I what to do is show in "center" section of dropdown the third level items. Basically if a second level menu item has a third level. I want that to be displayed in center section of dropdown. It's kinda confusing to explain so here's some menu code.

<div id="nav">
  <ul id="menulist">
{def $goleft = ezini( 'TopDrop', 'goleft', 'design.ini' )
	 $item_class = array()
	 $root_node = fetch( 'content', 'node', hash( 'node_id', 2 ) ) 
	 $top_items = fetch( 'content', 'list', hash( 'parent_node_id', $root_node.node_id,

				'class_filter_type', 'include',
				'class_filter_array', array( 1, 11, 19, 23, 44 ),
				'sort_by', $root_node.sort_array ) )

	 $top_items_count = $top_items|count()
	 $children = 0
	 $featured = 0
	 $current_node_in_path = first_set($pagedata.path_array[1].node_id, 0  )
     $current_node_in_path_2 = first_set($pagedata.path_array[2].node_id, 0  )
       $current_node_in_path_3 = first_set($pagedata.path_array[3].node_id, 0  )}
	
{if $top_items_count}
	{foreach $top_items as $key => $item}
		{set $item_class = array()}
		{if $current_node_in_path|eq($item.node_id)}
            {set $item_class = array("selected")}
		{/if}
		{set $children = fetch( 'content', 'list', hash( 'parent_node_id', $item.node_id,

				'class_filter_type', 'include',
				'class_filter_array', array( 1, 11, 19, 23, 44 ),
				'sort_by', $item.sort_array ) ) }
		
		{if $key|eq(0)}
            {set $item_class = $item_class|append("firstli")}
        {/if}
        {if $top_menu_items_count|eq( $key|inc )}
            {set $item_class = $item_class|append("lastli")}
        {/if}
        {if $item.node_id|eq( $current_node_id )}
            {set $item_class = $item_class|append("current")}
        {/if}
    {* exclude utility node from menu *}
		{if $item.node_id|ne(162)}
    <li id="{$item.name|explode('&')|implode('_')|explode(' ')|implode('')}" {if $item_class} class="{$item_class|implode(" ")}"{/if}><a id="{$item.name}" class="menu {$item.name}" href={$item.url_alias|ezurl}>{$item.name}</a>
    {/if}
    {if $children|count()|gt(0)}
			{* SECOND LEVEL *}
      <ul>
        <li>
          <div id="m-panel-{$item.name}" class="m-panel">
            <ul class="colBase">
            {foreach $children as $key => $child_item}
						{set $item_class = array()}
                {if $current_node_in_path_2|eq($child_item.node_id)}
                    {set $item_class = array("selected")}
                {/if}
                {if $key|eq(0)}
                    {set $item_class = $item_class|append("firstli")}
                {/if}
                {if $children|count|eq( $key|inc )}
                    {set $item_class = $item_class|append("lastli")}
                {/if}
                {if $child_item.node_id|eq( $current_node_id )}
                    {set $item_class = $item_class|append("current")}
                {/if}
              <li {if $item_class} class="{$item_class|implode(" ")}"{/if}><a {if $children|count()|gt(0)}{/if} href={$child_item.url_alias|ezurl}>{$child_item.name}
              </a></li>
              {/foreach}
            </ul>

{* THIS IS WHERE THE PROBLEM BEGINS *}
             {* THIRD LEVEL *}
            <ul class="centerCol first">
              <ul class="colLeft split">
              	<li class="firstli"><span>{$child_item.name}</span></li>{* THIS SHOULD DISPLAY SECOND LEVEL ITEM NAME THAT HAS THIRD LEVEL  *}
              {foreach $children as $key => $child_item}
							{set $item_class = array()}
                	{if $current_node_in_path_3|eq($child_item.node_id)}
                    	{set $item_class = array("selected")}
                	{/if}
                	{if $children|count|eq( $key|inc )}
                    {set $item_class = $item_class|append("lastli")}
                	{/if}
                {* THIS SHOULD OUTPUT THIRD LEVEL ITEMS *}
                <li {if $item_class} class="{$item_class|implode(" ")}"{/if}><a {if $children|count()|gt(0)}{/if} href={$child_item.url_alias|ezurl}>{$child_item.name}</a></li>
                {/foreach}
              </ul>
              <ul class="colLeft">
                <li class="firstli"><span>{$child_item.name}</span></li>{* THIS SHOULD DISPLAY SECOND LEVEL ITEM NAME THAT HAS THIRD LEVEL  *}
              {foreach $children as $key => $child_item}
							{set $item_class = array()}
                	{if $current_node_in_path_3|eq($child_item.node_id)}
                    	{set $item_class = array("selected")}
                	{/if}
                	{if $key|eq(0)}
                    	{set $item_class = $item_class|append("firstli")}
                	{/if}
                	{if $children|count|eq( $key|inc )}
                    {set $item_class = $item_class|append("lastli")}
                	{/if}
                	{if $child_item.node_id|eq( $current_node_id )}
                    	{set $item_class = $item_class|append("current")}
                {/if}
                {* THIS SHOULD OUTPUT THIRD LEVEL ITEMS *}
                <li {if $item_class} class="{$item_class|implode(" ")}"{/if}><a {if $children|count()|gt(0)}{/if} href={$child_item.url_alias|ezurl}>{$child_item.name}</a></li>
                {/foreach}
              </ul>
            </ul>
{* THIS IS WHERE THE PROBLEM ENDS *}

            {* FEATURE ITEM *}
            <ul class="centerCol last">
              <ul class="colLeft split">
              	<li class="first"> <span>Featured</span> </li>            
              	{set $featured = fetch( 'content', 'list', hash( 'parent_node_id', $item.node_id,
																 'class_filter_type', 'include',
																 'class_filter_array', array( 'article_mainpage' ),
																 'limit', 1,
																 'depth', 2,
																 'sort_by', array( 'published', false() ) ) ) }

								{if $featured|count|gt(0)}
                <li> <a href={$featured.0.url_alias|ezurl} title="Featured"> Feature of the Month
			{attribute_view_gui attribute=$featured.0.data_map.image image_class=articlelist}
			</a> 
      					</li>
                {/if}
              </ul>
            </ul>
          </div>
        </li>
      </ul>
    {/if}
    </li>
    {delimiter}
    <li class="divider">/</li>
    {/delimiter}
  {/foreach}
{/if}
  </ul>
</div>


This code outputs this for third level menu items

{* THIS IS WHERE THE PROBLEM BEGINS *}
{* THIRD LEVEL *}
<ul class="centerCol first">
<ul class="colLeft split">
<li class="firstli"><span>defexclusive-interviews, music, videos & more</span></li>
<li><a href="/public/culture/latest">Latest</a></li>
<li><a href="/public/culture/feature">Feature</a></li>
<li><a href="/public/culture/hip-hop-corner">Hip Hop Corner</a></li>
<li class="lastli"><a href="/public/culture/defexclusive-interviews-music-videos-more">defexclusive-interviews, music, videos & more</a></li>
</ul>
<ul class="colLeft">
<li class="firstli"><span>defexclusive-interviews, music, videos & more</span></li>
<li class="firstli"><a href="/public/culture/latest">Latest</a></li>
<li><a href="/public/culture/feature">Feature</a></li>
<li><a href="/public/culture/hip-hop-corner">Hip Hop Corner</a></li>
<li class="lastli"><a href="/public/culture/defexclusive-interviews-music-videos-more">defexclusive-interviews, music, videos & more</a></li>
</ul>
</ul>
{* THIS IS WHERE THE PROBLEM ENDS *}

I want it to output something like this

<ul class="centerCol first">
<ul class="colLeft split">
{* Second level item name *}
<li class="firstli"> <span>Hip-Hop Corner</span> </li>
{* Third level items *}
<li> <a href="#">Say Word?</a> </li>
<li> <a href="#">More Than Just Music</a> </li>
<li> <a href="#">Daily Sound-Off</a> </li>
</ul>
<ul class="colLeft">
{* Second level item name *}
<li class="firstli"> <span>DefExclusives</span> </li>
{* Third level items *}
<li> <a href="#">Interviews</a> </li>
<li> <a href="#">Music, Video's &amp; More</a> </li>
</ul>
</ul>

If anyone can help me with this I would greatly appreciate it.

I am, because I choose to be!

Veronique Jamilloux

Tuesday 20 October 2009 10:18:17 am

hi

I've the same need for my site access. I find this contribution : http://ez.no/developer/contribs/template_plugins/suckerfish_dropdown_menu, with the template and the css file. I don't try it yet, but may you wil find the solution to your problem.
Bye

URGI - INRA
Webmaster
Route de Saint Cyr
78000 Versailles

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

eZ debug

Timing: Jan 18 2025 15:55:52
Script start
Timing: Jan 18 2025 15:55:52
Module start 'layout'
Timing: Jan 18 2025 15:55:52
Module start 'content'
Timing: Jan 18 2025 15:55:53
Module end 'content'
Timing: Jan 18 2025 15:55:53
Script end

Main resources:

Total runtime0.9740 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0086 589.3438152.6250
Module start 'layout' 0.00860.0047 741.968839.4453
Module start 'content' 0.01340.9589 781.4141565.7344
Module end 'content' 0.97230.0017 1,347.148420.4766
Script end 0.9740  1,367.6250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3785160.0002
Check MTime0.00150.1493160.0001
Mysql Total
Database connection0.00110.112010.0011
Mysqli_queries0.906793.0900540.0168
Looping result0.00060.0623520.0000
Template Total0.930495.520.4652
Template load0.00210.215820.0011
Template processing0.928295.303320.4641
Template load and register function0.00010.012610.0001
states
state_id_array0.00130.135610.0013
state_identifier_array0.00150.151620.0007
Override
Cache load0.00190.1904510.0000
Sytem overhead
Fetch class attribute can translate value0.00060.065120.0003
Fetch class attribute name0.00170.175440.0004
XML
Image XML parsing0.00390.398320.0019
class_abstraction
Instantiating content class attribute0.00000.000840.0000
General
dbfile0.00600.6139220.0003
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs