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.
Target Attribute Menu Manager [Solved]
Target Attribute Menu Manager [Solved]
Last edited by jeverd01 on Thu May 20, 2010 3:44 pm, edited 1 time in total.
Re: Target Attribute Menu Manager
Function "isset()" accepts empty values - use "!empty()" instead.
Or there is handy smarty variable modifier "default"It will output '_self' if variable is empty.
Or there is handy smarty variable modifier "default"
Code: Select all
{$node->target|default:'_self'}
Re: Target Attribute Menu Manager
Thank you.