Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-30 07:46:17

amora
Member
From: Seattle
Registered: 2009-03-23
Posts: 12

highlight the page I'm on

Hey, so I’m having a hard time figuring out how to make a secondary navigation system work. Up front: I know how to use the conditional tags and change classes, which is something I usually do for my navigation in order to highlight which section the user is in. What I’m trying to do now, is create a number system for articles using keywords (or custom field) to reference the articles in my Episodes section.

Here’s the link: http://thesuperman.tv/newsite/

Here’s what I have in the Misc Form that is called on when the the section matches Episodes.

<txp:article_custom section="episodes" sort="ID"> <txp:permlink class="keywordOff"><txp:keywords /></txp:permlink> </txp:article_custom>

<txp:article limit="1" sort="ID" form="anEpisode" />

What I’d like to do is make it so when you’re on a specific episode, then its matching keyword (the number on the top row) changes class (so that it’s orange) and drops the permlink tag.

I tried using <txp:if_article_id> which works, but obviously doubles the keyword for the article. If I use an else tag, it shows up, but then if I leave the page and come back, it disappears. So clearly it doesn’t seem like a stable way to accomplish this.

Maybe I’m overlooking something very simple. But I’m just trying to do something I’ve never done with TXP, so any suggestions would be great. Again the basic premise is to just use a simple secondary navigation that is flexible, so that when my client adds more episodes, the number will show up automatically. (Saves me from actually writing out conditional statements for each number, each time a video is added.)

Thanks.

Offline

#2 2009-04-30 08:10:13

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: highlight the page I'm on

Something simple it is:

<txp:article_custom section="episodes" sort="ID">
		<txp:if_article_id>
				<span class="active">
					<txp:keywords />
				</span>
			<txp:else />
				<txp:permlink class="keywordOff">
					<txp:keywords />
				</txp:permlink>
		</txp:if_article_id>
</txp:article_custom>

Since TXP version 4.0.7 the if_article_id has worked in similiar way as the great rvm_if_thisarticle plugin; It checks if the current individual article is the same as the other call.

Last edited by Gocom (2009-04-30 08:11:22)

Offline

#3 2009-04-30 08:10:54

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: highlight the page I'm on

How do you used <txp:if_article_id />?

Does this won’t work?

<txp:article_custom section="episodes" sort="ID">
	<txp:if_article_id>
		<txp:keywords /> 
	<txp:else />
		<txp:permlink class="keywordOff"><txp:keywords /></txp:permlink> 
	</txp:if_article_id>
</txp:article_custom>

Ah, Gocom was earlier. :)

Last edited by trenc (2009-04-30 08:12:02)


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#4 2009-04-30 20:02:09

amora
Member
From: Seattle
Registered: 2009-03-23
Posts: 12

Re: highlight the page I'm on

It seems to work but then it fails. Kinda hard to describe, but if I’m viewing the page, then update the code (with either of those) it shows up and I can click around on the Episodes. BUT, if I go my about page and then return to the episodes page (or Default, since both “sections” call up that form), then it disappears and only the Episode Title shows.

I think it would be hard for me to demonstrate this, but maybe I’ll just add that code for now, and you can at least see how the keywords don’t appear. Strangely, it does seem to be there in the debugging report—but I’m not an expert with debugging…

Thanks!

edit: This is what I added:

<txp:article_custom section="episodes" sort="ID">
   <txp:if_article_id>
      <span class="keywordOn"><txp:keywords /></span>
   <txp:else />
      <txp:permlink class="keywordOff"><txp:keywords /></txp:permlink>
   </txp:if_article_id>
</txp:article_custom>

Last edited by amora (2009-04-30 20:28:02)

Offline

#5 2009-04-30 20:18:08

amora
Member
From: Seattle
Registered: 2009-03-23
Posts: 12

Re: highlight the page I'm on

Also, as I mentioned initially, if I add this, it just duplicates the keyword of the page you’re on. But that’s obvious.

<txp:article_custom section=“episodes” sort=“ID”>
   <txp:if_article_id>
      <span class=“keywordOn”><txp:keywords /></span>
   </txp:if_article_id>
      <txp:permlink class=“keywordOff”><txp:keywords /></txp:permlink>
</txp:article_custom>

Last edited by amora (2009-04-30 20:28:40)

Offline

#6 2009-04-30 20:30:13

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: highlight the page I'm on

It’s because if_article_id only works on an individual article page. So on your section home page, though it’s showing the same content, it doesn’t do anything.
You’ll need some other conditionals to display the navigation on the section home page as well.

Offline

#7 2009-04-30 22:23:03

amora
Member
From: Seattle
Registered: 2009-03-23
Posts: 12

Re: highlight the page I'm on

Ah, makes perfect sense. I knew it was something simple in the fine print.

I’m not sure how to use conditionals to tackle what I want. But I could just bypass any reference to the (episode) section page, right? Meaning, if Episode 1 is always what I want on my site “homepage” or to be what you see when you click Episodes, I could just link directly to it in all instances… Then I start off in an individual article, and navigate to other individual articles…

Though, I guess I would have to reroute the default url?

Thanks again for all comments.

Last edited by amora (2009-04-30 22:24:09)

Offline

Board footer

Powered by FluxBB