Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-24 14:40:12

krisleech
Member
Registered: 2005-02-24
Posts: 11
Website

highlight the link to the page being viewed?

I have a unordered list of links for my menu (about, contact etc.)

If say the “contact us” link is clicked is there a way to have the contact us link in the menu change colour (using CSS)?

It must only change colour when that page is being viewed so using a:visited pseudo class will not work as it would stay coloured.

<code>
<td id=“Menu”> <ul> <li><a href=“domain.com”>home page</a></li> <li><a href=“what-we-do”>what we do</a></li> <li><a href=“about-learning-space”>about learning-space</a></li> <li><a href=“who-are-we”>who are we</a></li> <li><a href=“contact”>contact us</a></li> <li><a href=“links”>links</a></li> <li><a href=“news”>latest news</a></li> </ul> </td>
</code>

Many thanks, K.

Last edited by krisleech (2005-11-24 14:46:57)

Offline

#2 2005-11-24 14:48:17

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: highlight the link to the page being viewed?

There’s more than one way to do it. You might be interested in a plugin that does the thinking for you. :)

Offline

#3 2005-11-24 15:03:38

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: highlight the link to the page being viewed?

Or avoid using a plug-in by using <code><txp:if_section name=“sectionName”><txp:else /></txp:if_section></code> tags. It keeps those damnable database calls at bay. ;)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#4 2005-11-24 16:13:43

krisleech
Member
Registered: 2005-02-24
Posts: 11
Website

Re: highlight the link to the page being viewed?

The plug is ideal but it only works for one section… for some reason, both sections have the same template copy pasted but it only highlights the link for the hompage…

<code> <txp:if_section name=“sectionName”><txp:else /></txp:if_section></code>
might work but the articles are all in the same section :)

Many thanks, K.

Offline

#5 2005-11-25 01:33:52

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: highlight the link to the page being viewed?

Well if the articles were in different categories you could use <code> <txp:if_category name=“categoryName”><txp:else /></txp:if_category></code> for those links.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#6 2005-11-25 09:41:36

krisleech
Member
Registered: 2005-02-24
Posts: 11
Website

Re: highlight the link to the page being viewed?

> thebombsite wrote:

> Well if the articles were in different categories you could use <code> <txp:if_category name=“categoryName”><txp:else /></txp:if_category></code> for those links.

There not in different categories either :) They are all in the same section (about) and same category (show_on_menu).

Offline

#7 2005-11-25 19:28:21

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: highlight the link to the page being viewed?

You’d do it yourself then, something like this.

Last edited by Mary (2005-11-25 19:28:32)

Offline

#8 2005-11-26 03:00:49

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: highlight the link to the page being viewed?

I’m not sure that would work for the article links either Mary. It relies on the “body” tag id for the “current state” which isn’t going to differentiate between different articles as they are in the same section and category.

Mmmm. I think we could do with a <code><txp:if_article_id id=“23”></code> tag. Any plug-ins do that?


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#9 2005-11-26 11:17:07

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: highlight the link to the page being viewed?

Well no, you could easily use any other tag. For the sake of the example, say each of the articles are numbered 1 through 7.

<div id="article-<txp:article_id">
        <txp:body />
</div>
<td id="Menu">
    <ul>
        <li id="link-1"><a href="domain.com">home page</a></li>
        <li id="link-2"><a href="what-we-do">what we do</a></li>
        <li id="link-3"><a href="about-learning-space">about learning-space</a></li>
        and so on...
    </ul>
</td>
#Menu #article-1 #link-1 {
/* when on home page, style the home page link differently */ 
}

Got the idea?

Offline

#10 2005-11-26 13:07:41

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: highlight the link to the page being viewed?

Oh now you’re just getting all technical on me. I didn’t think of that one. :(


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#11 2005-11-26 14:49:00

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: highlight the link to the page being viewed?

Mary gets technical on everybody. ;)
Don’t feel bad Stuart. I keep being amazed at how we can use the tags inside the html differently.

Its like watching cirque de sole all inside a text editor and a browser.

:)

Matthew


Offline

#12 2005-11-27 16:41:39

krisleech
Member
Registered: 2005-02-24
Posts: 11
Website

Re: highlight the link to the page being viewed?

<code><div id=“article-<txp:article_id”></code>

That will work, but it would be better if the plugin Im trying worked because it is more dynamic so requires less css rules. With the above I would need one css rule per menu item, with the plugin it generates the menu UL and adds a style to the A of the article being viewed…

But if it works then I’m going to impliement it until I can get the plugin working, thanks.

Offline

Board footer

Powered by FluxBB