Target Attribute Menu Manager [Solved]

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
jeverd01
Forum Members
Forum Members
Posts: 20
Joined: Thu May 20, 2010 2:00 am

Target Attribute Menu Manager [Solved]

Post by jeverd01 »

I have an issue, I edited a menu template a little bit and found somewhere a while ago where the smarty code required to add the target attribute. The issue I am having is the target attribute is displaying in my menu items even if it is blank. This is causing w3c validation errors since the attribute can't be empty. Here is my menu template code.

{* CSS classes used in this template:
.activeparent - The top level parent when a child is the active/current page
li.active0n h3 - n is the depth/level of the node. To style the active page for each level separately. The active page is not clickable.
.clearfix - Used for the unclickable h3 to use the entire width of the li, just like the anchors. See the Tools stylesheet in the default CMSMS installation.
li.sectionheader h3 - To style section header
li.separator - To style the ruler for the separator *}
{if $count > 0}{foreach from=$nodelist item=node}{if $node->depth > $node->prevdepth}{repeat string="" times=$node->depth-$node->prevdepth}{elseif $node->depth prevdepth}{repeat string="" times=$node->prevdepth-$node->depth}{elseif $node->index > 0}{/if}{if $node->parent == true or ($node->current == true and $node->haschildren == true)}url}" {if isset($node->target)}target="{$node->target}" {/if}>{$node->menutext}{elseif $node->haschildren == true and $node->type != 'sectionheader' and $node->type != 'separator'}url}" {if isset($node->target)}target="{$node->target}" {/if}>{$node->menutext}{elseif $node->current == true}{$node->menutext}{elseif $node->type == 'sectionheader'}{$node->menutext}{elseif $node->type == 'separator'} {else}url}" {if isset($node->target)}target="{$node->target}" {/if}>{$node->menutext}{/if}{/foreach}{repeat string="" times=$node->depth-1}{/if}

I thought the if statement

{if isset($node->target)}

checks if the node target is set then only prints it if it is set? All of the links that are outputted have none selected for target. I am using 1.6.6 "Bonde".

I thought about just setting the attribute to self inside of the cms but I have 200+ pages and I really don't feel like doing this, seems like I am missing something.

Thanks in advance.
Last edited by jeverd01 on Thu May 20, 2010 3:44 pm, edited 1 time in total.
Peciura

Re: Target Attribute Menu Manager

Post by Peciura »

Function "isset()" accepts empty values - use "!empty()" instead.

Or there is handy smarty variable modifier "default"

Code: Select all

{$node->target|default:'_self'}
It will output '_self' if variable is empty.
jeverd01
Forum Members
Forum Members
Posts: 20
Joined: Thu May 20, 2010 2:00 am

Re: Target Attribute Menu Manager

Post by jeverd01 »

Thank you.
Post Reply

Return to “Layout and Design (CSS & HTML)”