My first custom menu

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
cb2004
Power Poster
Power Poster
Posts: 317
Joined: Wed Jul 04, 2007 3:39 pm

My first custom menu

Post 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.
Last edited by cb2004 on Tue Dec 11, 2007 1:47 pm, edited 1 time in total.
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: My first custom menu

Post 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}
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
cb2004
Power Poster
Power Poster
Posts: 317
Joined: Wed Jul 04, 2007 3:39 pm

Re: My first custom menu

Post by cb2004 »

Superb. No idea what the code does, but I modified it slightly and now, its perfect :).
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: My first custom menu

Post 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}
Last edited by kermit on Fri Dec 14, 2007 10:16 pm, edited 1 time in total.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Post Reply

Return to “CMSMS Core”