Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-12 23:58:03

rblumberg
Member
From: Cincinnati
Registered: 2005-10-01
Posts: 10
Website

Change CSS Class info depending on page

I’m a newbie to TextPattern; this is probably something that’s easy and obvious, and I’ve missed it because I’m trying to make it more complicated. But here goes.

I have a navigational menubar at our Dharma Study Group website. I’d like the “navbar” form that displays that menu to insert different CSS class info for the current page than it does for other pages. The menubar is implemented as an inline list; when the form is inserted into the “About” page, for example, I’d like the “About” list item to include the tag attribute ‘class=“current”’, while the other menu items would include ‘class=“external”’. That way I could style the menu items via CSS.

Can I use a conditional txp tag to do that?

If you can point me to the documentation that shows me how to do what I want, that would be great.

Thanks.

Richard

Offline

#2 2005-12-13 00:37:26

Elenita
Member
From: Falls Church, VA
Registered: 2004-05-16
Posts: 407
Website

Re: Change CSS Class info depending on page

Welcome to Textpattern. Assuming your about page is in a section named “about”:

<code><txp:if_section name=“about”>
<div class=“current”>Lorem ipsum dolor sit amet</div>
<txp:else />
<div class=“external”>Lorem ipsum dolor sit amet</div>
</txp:if_section></code>

See <a href=“http://textpattern.net/wiki/index.php?title=Txp:if_section”>txp:if_section</a> and the rest of the tag index for code examples.

Offline

#3 2005-12-13 01:27:52

Neko
Member
Registered: 2004-03-18
Posts: 458

Re: Change CSS Class info depending on page

If I’m not wrong you could just apply a class to the body tag using the conditionals Elenita pointed out and then trying this.

Offline

#4 2005-12-13 02:07:43

rblumberg
Member
From: Cincinnati
Registered: 2005-10-01
Posts: 10
Website

Re: Change CSS Class info depending on page

Thanks, folks. That’s exactly what I was looking for. Now I know a little more about TextPattern, and my site is working a little more like I want it to.

Richard

Offline

Board footer

Powered by FluxBB