Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
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
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
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
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
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
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