Textpattern Forum

You are not logged in. Register | Login | Help

#1 2012-07-02 15:12:34

quicknquiet
Member
From: Moscow
Registered: 2012-07-02
Posts: 11

How to deactivate and mark a link to current page

Hi guys, I’m new to here, so please don’t shoot me at once. The question is in topic – For general site navigation I use TXP sections as menu items, which are displayed with this tag:

<txp:section_list break=“li” include_default=“0” sort=“name asc” />

which produces such html code:

<ul>
<li><a href=“http://mysite.com/section1”>Section 1</a></li>
<li><a href=“http://mysite.com/section2”>Section 2</a></li>
<li><a href=“http://mysite.com/section3”>Section 3</a></li>
<li><a href=“http://mysite.com/section4”>Section 4</a></li>
</ul>

In CSS i have different styles for regular and hovered links and the idea is to display actual menu item as hovered and make this link inactive when the corresponding section is already active.

May be there are solutions for this?

Offline

#2 2012-07-02 15:22:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,970
Website

Re: How to deactivate and mark a link to current page

You could try

<txp:section_list wraptag="ul" break="li">
<txp:if_section name='<txp:section />'> 
<txp:section title="1" />
<txp:else />
<txp:section title="1" link="1" />
</txp:if_section>
</txp:section_list>

Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#3 2012-07-02 15:30:39

uli
Moderator
From: Cologne/Köln
Registered: 2006-08-15
Posts: 3,086

Re: How to deactivate and mark a link to current page

See also example 3 of the section_list page on TXP Docs. (Bookmark the Tag Reference.)

Edit: Now that I read the topic’s title again, I think colak’s solution is the one you should choose. I was mislead by the hover/active/inactive terminology.

Last edited by uli (2012-07-02 15:39:50)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Online

#4 2012-07-02 15:46:32

quicknquiet
Member
From: Moscow
Registered: 2012-07-02
Posts: 11

Re: How to deactivate and mark a link to current page

Thank you all very much – sometimes mental support is enough :) Solution:

In page template:

<div id="nav2">
<txp:section_list active_class="current" break="li" include_default="0" wraptag="ul" />
</div>

In CSS:

#nav2 ul li a:hover { color:#CC0000;}
#nav2 ul li a.current { color:#CC0000; pointer-events: none; cursor: default;}

Last edited by quicknquiet (2012-07-02 15:50:52)

Offline

#5 2012-07-02 16:04:09

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,970
Website

Re: How to deactivate and mark a link to current page

Your solution does highlight the active section but it does not deactivate the link. Having said that, the link is useful when one is not on the front page of the section or when they are on an article page so I would change the css to #nav2 ul li a.current { color:#cccccc;} or another colour of your liking.


Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

Board footer

Powered by FluxBB