Page 1 of 1

[closed] Need 'menu template expert' help

Posted: Fri Dec 18, 2009 7:52 pm
by Gamonon
Hiding parts of the menu with FEU works almost perfect.

But when I checked the html source of the pages, I found a lot of errors. The reason is that the pages that contain 'restricted' in the extra1 field, course extra tags to show up in the html source. If I don't show these pages in the menu, there are no errors. Somewhere in the menu template these tags are added allthough the should be skipped.

The template should work fine like this, as others use it too. ( http://forum.cmsmadesimple.org/index.ph ... 533.0.html ). I have copied and used this template also but it generates the same problem. Shoeld be as it is the same as I am using.

The template works without generating errors if I leave these rows out:


{if ($node->extra1=='restricted' and $ccuser->loggedin()) or $node->extra1=='' }
...
{/if}  {* node->extra1 *}


But then of course it shows the parts of the menu that should be hidden. I have tried and done all I can think of, read the manual of Robert Campbell and moved all parts of the template up and down. Could someone point me the the obvious simple solution? Thanks!

The template looks like this:

Code: Select all

{strip}
{if $count > 0}

<ul class="art-menu">

{foreach from=$nodelist item=node}

{if $node->depth > $node->prevdepth}

{repeat string="<ul>" times=$node->depth-$node->prevdepth}

{elseif $node->depth < $node->prevdepth}

{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}

</li>

{elseif $node->index > 0}</li>

{/if}


{if ($node->extra1=='restricted' and $ccuser->loggedin()) or $node->extra1=='' }

{if $node->current == true && $node->depth == 1}

<li><a href="{$node->url}" class="active"><span class="l"></span><span class="r"></span><span class="t">{$node->menutext}</span></a>

{elseif $node->depth == 1}
<li><a href="{$node->url}"><span class="l"></span><span class="r"></span><span class="t">{$node->menutext}</span></a>

{elseif $node->current == true && $node->depth != 1}

<li><a href="{$node->url}" {if $node->accesskey != ''} accesskey="
{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}{if $node->target != ''} target="{$node->target}"{/if}><dfn>{$node->hierarchy}: </dfn><b>{$node->menutext}</b></a>

{elseif $node->type == 'sectionheader'}
<li class="sectionheader">{$node->menutext}

{elseif $node->type == 'separator'}
<li class="separator" style="list-style-type: none;"> <hr />

{else}
<li><a href="{$node->url}"{if $node->accesskey != ''} accesskey="{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}{if $node->target != ''} target="{$node->target}"{/if}>{$node->menutext}</a>
{/if}

{/if} 

{/foreach}
{repeat string="</li></ul>" times=$node->depth-1}</li>
</ul>
{/if}

{/strip}


Re: Need 'menu template expert' help

Posted: Sat Dec 19, 2009 2:37 am
by Gamonon
Seems I am thye expert myself after all.
After several hours of trying I managed to change the menu template into a working one resulting
in W3C complied html code. That is without a bunch of outlaw 's

The line {if ($node->extra1=='restricted' and $ccuser->loggedin())  or $node->extra1==''}
moved up a couple of rows and

{repeat string="" times=$node->depth-1} changed into
{repeat string="" times=$node->depth-2}

Don't ask me how or why it works now as I don't have a clue. I just hope it will stay that way :'(

Complete working menu code looks now as

Code: Select all

{strip}

{if $count > 0}

<ul class="art-menu">

{foreach from=$nodelist item=node}

{if ($node->extra1=='restricted' and $ccuser->loggedin())  or $node->extra1==''}

{if $node->depth > $node->prevdepth}

{repeat string="<ul>" times=$node->depth-$node->prevdepth}

{elseif $node->depth < $node->prevdepth}

{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>

{elseif $node->index > 0}</li>

{/if}

{if $node->current == true && $node->depth == 1}

<li><a href="{$node->url}" class="active"><span class="l"></span><span class="r"></span><span class="t">{$node->menutext}</span></a>

{elseif $node->depth == 1}
<li><a href="{$node->url}"><span class="l"></span><span class="r"></span><span class="t">{$node->menutext}</span></a>

{elseif $node->current == true && $node->depth != 1}

<li><a href="{$node->url}" {if $node->accesskey != ''} accesskey="
{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}{if $node->target != ''} target="{$node->target}"{/if}><b>{$node->menutext}</b></a>

{elseif $node->type == 'sectionheader'}
<li class="sectionheader">{$node->menutext}

{elseif $node->type == 'separator'}
<li class="separator" style="list-style-type: none;"> <hr />

{else}
<li><a href="{$node->url}"{if $node->accesskey != ''} accesskey="{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}{if $node->target != ''} target="{$node->target}"{/if}>{$node->menutext}</a>

{/if}

{/if}{* node->extra1 *}

{/foreach}

{repeat string="</li></ul>" times=$node->depth-2}</li>
</ul>

{/if}

{/strip}