[SOLVED] Problem with generated menu Code

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
force2083
Forum Members
Forum Members
Posts: 26
Joined: Wed Jun 11, 2008 6:32 am

[SOLVED] Problem with generated menu Code

Post by force2083 »

I'm using CMS Made Simple 1.3 "Cuba" (but had this Problem with other versions too)

There are some problems with the menu...

I add following code to the template:

Code: Select all

<!-- start menu -->
<div id="navigation">
<ul>
{menu template='Layout01' number_of_levels='1'}
</ul>
</div>
<!-- end menu -->
and the menu template looks like this:

Code: Select all

 {if $count > 0}
{foreach from=$nodelist item=node}
 <li><a href="{$node->url}" title="{$node->titleattribute}" {if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a>
{if $count > ($node->index+1)} </li>
{/if}
{/foreach}
{/if}
the expected output should look like this:

Code: Select all

<!-- start menu -->
<div id="navigation">
<ul>
  <li><a href="http://www.url.de/cmsms/" title="Home Page, shortcut key=1" >Home</a>
  </li>
  <li><a href="http://www.url.de/cmsms/index.php?page=link1" title="" >Link1</a>
  </li>
  <li><a href="http://www.url.de/cmsms/index.php?page=link2" title="" >Link2</a>
  </li>
  <li><a href="http://www.url.de/cmsms/index.php?page=link3" title="" >Link3</a>
  </li>
  <li><a href="http://www.url.de/cmsms/index.php?page=link4" title="" >Link4</a>
  </li>
  <li><a href="http://www.url.de/cmsms/index.php?page=link5" title="" >Link5</a>
  </li>
</ul>
</div>
<!-- end menu -->
but the real output forget the last -tag
did I do something wrong or is this a bug?

Dirk
Last edited by force2083 on Wed Jun 11, 2008 8:03 am, edited 1 time in total.
rvdv
Forum Members
Forum Members
Posts: 62
Joined: Wed Oct 31, 2007 2:16 pm

Re: Problem with generated menu Code

Post by rvdv »

Don't think it's a bug. I checked it on a test setup and i have 10 menu items. My $count var shows me 10 like it should. But the $node->index starts with 0. This means that the last $node->index+1 is the same as your $count.

At the moment you're checking if $count is higher then $node->index+1 but it should be equal to or higher then. So your menu should be:

Code: Select all

{if $count > 0}
	{foreach from=$nodelist item=node}
		<li><a href="{$node->url}" title="{$node->titleattribute}" {if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a>
		{if $count >= $node->index+1} 
			</li>
		{/if}
	{/foreach}
{/if}
Good luck ;)
force2083
Forum Members
Forum Members
Posts: 26
Joined: Wed Jun 11, 2008 6:32 am

Re: Problem with generated menu Code

Post by force2083 »

Oh man... what a small sign can do.  :D
Thanks a lot.

But if i remember it right this was a default Menu Example (included in the standard installation), maybe it should be changed there too???
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: [SOLVED] Problem with generated menu Code

Post by Dr.CSS »

I've seen every menu template for the last 2 plus years and none of them had index+1... iirc...
rvdv
Forum Members
Forum Members
Posts: 62
Joined: Wed Oct 31, 2007 2:16 pm

Re: [SOLVED] Problem with generated menu Code

Post by rvdv »

mark wrote: I've seen every menu template for the last 2 plus years and none of them had index+1... iirc...
Then check again... It's the 'simple_menu' on this page. :)
force2083
Forum Members
Forum Members
Posts: 26
Joined: Wed Jun 11, 2008 6:32 am

Re: [SOLVED] Problem with generated menu Code

Post by force2083 »

Ok if I understand it right, it's enough to use this code and leave the 2nd if clause

Code: Select all

{if $count > 0}
 {foreach from=$nodelist item=node}
  <li><a href="{$node->url}" title="{$node->titleattribute}" {if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}</a></li>
 {/foreach}
{/if}
rvdv
Forum Members
Forum Members
Posts: 62
Joined: Wed Oct 31, 2007 2:16 pm

Re: [SOLVED] Problem with generated menu Code

Post by rvdv »

Yes, in the simple menu they use that if so the menu doesn't shows a | after the last menu item.
Post Reply

Return to “CMSMS Core”