Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2008-01-24 21:05:21
- simsim
- Member
- Registered: 2006-05-06
- Posts: 70
A "current" CSS class
Hello,
I know TXP provides a active_class
attribute for the <txp:section_list>
and <txp:category_list>
tags. However, that attribute becomes useless when trying to trigger a current status for every page within a single section or category. I have a secondary navigation system on the left sidebar of the site. I want to trigger a class="active"
attribute on the anchors when every page is shown. For example:
About Us
Who We Are
What We do
Our Mission
Values
Etc Etc
When on the “Our Mission” page, the menu would be:
About Us
Who We Are
What We Do
« Our Mission
Values
Etc Etc
Offline
Re: A "current" CSS class
What tags are you using for the sub-menu? Are the “who we are” etc sections? In this case, you can use something like:
<ul>
<li><a <txp:if_section name="">class="active" </txp:if_section>href="<txp:site_url />">Home</a></li>
<li><a <txp:if_section name="who-we-are">class="active" </txp:if_section>href="<txp:site_url />who-we-are/">Who we are</a></li>
</ul>
Last edited by jstubbs (2008-01-24 21:13:50)
Offline
#3 2008-01-24 21:20:45
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: A "current" CSS class
If those are articles, have a look at glx_hl_current.
Offline
#4 2008-01-24 21:29:04
- simsim
- Member
- Registered: 2006-05-06
- Posts: 70
Re: A "current" CSS class
The sub-menu is a usual unordered list. Sections aren’t my problem. I want to trigger the active class as per individual article not as per section. This usually works with sections because a site wouldn’t have many sections, and putting a section identifier in the body element (i.e. <body id="section-name">
) will do the trick since the CSS code will be simple and static.
The menu is triggered as per section, so in every section only the relevant articles show up in the sub-menu. I want the link of the current article to have different styling.
Offline
Offline
#6 2008-01-24 21:37:38
- simsim
- Member
- Registered: 2006-05-06
- Posts: 70
Re: A "current" CSS class
@Els:
Thanks. I’m looking into it.
@jstubbs:
I’ve thought about it, but I’m using clean URLs which have made that tag useless.
Offline
#7 2008-01-24 21:43:25
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: A "current" CSS class
if_article_id should also work with clean URLs. Use it in your article form, together with another plugin:
<li<txp:if_individual_article><txp:asy_wondertag><txp:if_article_id id="<txp:article_id />"> class="active"</txp:if_article_id></txp:asy_wondertag>><txp:permlink><txp:title /></txp:permlink></li>
Offline
Pages: 1