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 & More</a> </li>
</ul> </ul> If anyone can help me with this I would greatly appreciate it.
I am, because I choose to be!
|