Getting current page to say highlighted/active

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
jospanner
Forum Members
Forum Members
Posts: 105
Joined: Tue Mar 25, 2008 11:34 pm

Getting current page to say highlighted/active

Post by jospanner »

Some help is required please.

Site in progress http://pearsaa2.memset.net/~johnson - The hover state for both vertical and horizontal navigation shows as red and I want that to remain whilst that page is active. I have hunted high and low as to how to achieve this but can't find any tips.

Can anyone help please? Thanks in advance!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Getting current page to say highlighted/active

Post by Dr.CSS »

Has to do with using JS for hover etc. instead of css and you are using a menu template that has no class for active page like the default ones have, must be minimal template...
jospanner
Forum Members
Forum Members
Posts: 105
Joined: Tue Mar 25, 2008 11:34 pm

Re: Getting current page to say highlighted/active

Post by jospanner »

Ah - so by template you mean .tpl? Here is the one I am using:

{* 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->current == true}
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->hierarchy}: {$node->menutext}

{elseif $node->parent == true}
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->hierarchy}: {$node->menutext}

{elseif $node->type == 'sectionheader'}
{$node->menutext}

{elseif $node->type == 'separator'}


{else}
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->hierarchy}: {$node->menutext}

{/if}

{/foreach}
{repeat string="" times=$node->depth-1}

{/if}
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Getting current page to say highlighted/active

Post by Dr.CSS »

Yes, notice...

{if $node->current == true}
url}"............

All kinds of things but no class='active' on li or a...
jospanner
Forum Members
Forum Members
Posts: 105
Joined: Tue Mar 25, 2008 11:34 pm

Re: Getting current page to say highlighted/active

Post by jospanner »

Okay - you need to be gentle with me now as I can get my head around html/css and even a few smarty tags but the coding in a .tpl is a new territory.

So do I need to add

{if $node->current == active}
url}"............

If so , does it matter the order in which it goes?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Getting current page to say highlighted/active

Post by Dr.CSS »

The menu you pasted doesn't have any classes to denote active etc. so you would need to add them or just use a different menu template...

{if $node->current == active}
url}"..........

Would give both the li and the a link a class of active when it's the current page so you could use this for CSS to make it look like it does on hover, it may not work if you don't use CSS to do the hover state...
Post Reply

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