Page 1 of 1
My first custom menu
Posted: Tue Dec 11, 2007 1:40 pm
by cb2004
I have only been using this software a day. Think its great and I have barely touched it.
I am trying to create my first menu with seperators and only showing a few links.
My call to the menu is this:
{menu template=bottom items=links,contact-us,careers,home}
My menu code is this:
{foreach from=$nodelist item=node}
{if $node->current == true}
{$node->menutext}
{elseif $node->type == 'separator'}
|
{else}
url}">{$node->menutext}
{/if}
{/foreach}
Very basic I know. But the only thing I do not have working is the seperator. Does the items param not call the child pages as the seperator is a child? Is this why they are not showing?
Am I heading in the right direction?
Cheers.
Re: My first custom menu
Posted: Tue Dec 11, 2007 3:57 pm
by kermit
"items" uses page aliases; only those items are shown. separators don't have a page alias to reference...
try something like this instead.. output looks like this:
[iurl=#]Link Text[/iurl] | Current Page | [iurl=#]Link Text[/iurl] | [iurl=#]Link Text[/iurl] | [iurl=#]Link Text[/iurl]
Code: Select all
{if $count > 0}
<p class="links">{strip}
{counter start=0 name=itemcount assign=itemcount print=false}
{foreach from=$nodelist item=node}
{counter name=itemcount print=false}
{if $itemcount ne '1'} | {/if}
{if $node->current eq true}<span class="current">{$node->menutext}</span>
{else}<a href="{$node->url}">{$node->menutext}</a>
{/if}
{/foreach}
{/strip}</p>
{/if}
Re: My first custom menu
Posted: Wed Dec 12, 2007 12:42 pm
by cb2004
Superb. No idea what the code does, but I modified it slightly and now, its perfect

.
Re: My first custom menu
Posted: Fri Dec 14, 2007 10:13 pm
by kermit
{* "if no menu items to process, then don't bother" *}
{if $count > 0}
{* this wraps your menu in a tag so you can style it; the strip removes extra linefeeds and spaces from output *}
{strip}
{* this counts the menu items; a quick-n-dirty way to skip the separator before the first item *}
{counter start=0 name=itemcount assign=itemcount print=false}
{* this is the start of the main loop for the menu *}
{foreach from=$nodelist item=node}
{* this counts up one (from zero, above) *}
{counter name=itemcount print=false}
{* add a separator before all but the first item *}
{if $itemcount ne '1'} | {/if}
{* if current page, add a span and class so you can style it different, didn't *need* the class (p.links span would've been enough), but added it to make the purpose of the span obvious. *}
{if $node->current eq true}{$node->menutext}
{* otherwise it's "just a link" *}
{else}url}">{$node->menutext}
{/if}
{* cycle through all menu items *}
{/foreach}
{* the end, closing open tags *}
{/strip}
{/if}