Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Need "active" class in Article List
Hi, after hours of searching through forums, I can’t seem to get an answer to my question. I hope you all can help.
In plain english, I want to have a page with two columns. The left column is a list of article titles. If you click an article’s title, it should display the article in the right column. That part works. The part I can’t seem to figure out is how to give the article title (on the left side) an “active” class when it’s being displayed.
First my code(condensed for easy reading):
<div id="left">
<txp:article_custom section="services" wraptag="ul" />
<li><a href='<txp:permlink />'><txp:title /></a></li>
</txp:article_custom>
</div>
<div id="right">
<txp:article limit="1" />
</div>
I think the problem here is context. The article list on the left is not really aware of the article being displayed on the right. I tried creating a variable, so that whenever an article is displayed, it saves it’s article_id to a variable called “article_id.” In the left column I’d check to see if the article title’s id was the same as the id stored in the variable. The problem there is, I’m doing the check in the left column, before the article is processed in the right column, so <txp:variable name="article_id" />
always return nothing.
Maybe my overall approach is wrong. My first idea was to create a series of categories and assign articles to those categories. Then you’d display the category list on the left and the article for that category on the right. It seemed like a misuse of categories, since there would always be one article per category. So I went down my current path.
Any help or advice is appreciated.
- John
Last edited by johnsanders (2009-02-03 09:25:48)
Offline
Re: Need "active" class in Article List
Try add this
<txp:if_article_id id='<txp:article_id />'> class="active"</txp:if_article_id>
to your li
as follows:
<li<txp:if_article_id id='<txp:article_id />'> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
Note: the single quotes in the tag inside the tag equates to “parse this tag and insert the result” (v4.07+). In other situations you can use double-quotes.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Need "active" class in Article List
before 4.0.7, I’ve used glx_hl_current
~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~
Offline
Re: Need "active" class in Article List
jakob,
I had previously tried that, but because of the context (at least I think that’s the culprite), the if_article_id
tag on the left doesn’t know what’s being displayed on the right. I tested it by adding <txp:article_id />
right before the closing </li>. Each line shows it’s own article ID, regardless of what’s being displayed on the right.
I’m going to move next to Kemie’s suggestion, but the plugin’s download area seems to be gone, and it’s showing an error page in another language I can’t understand. I’ll keep looking.
Thanks again jakob,
-john
Offline
Re: Need "active" class in Article List
glx_hl_current works! To figure out how to download it, it took some digging through one of the author’s previous posts. He’s no longer supporting the plugin, and the original download location seems to be gone. As of the posting of this article, the place to get this plugin (and all of his other plugins) is http://www.markupartist.com/files/.
The format of the plugin text is different than most plugin’s I’ve seen. But he still has the big long string of text inside the file. Just copy that text and paste like any other plugin and you’re good to go. I’m using Textpattern 4.0.8 and it seems to work fine.
Thanks Kemie!
- John
Offline
Re: Need "active" class in Article List
ah, right. I stand corrected. Maybe your variable idea would work, if you invoke it first at the top of the page (you can use txp:article more than once on a page). You should also be able to use rvm_if_this_article.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Need "active" class in Article List
No need to complicate the using of txp:if_article_id
:
<txp:article_custom wraptag="ul">
<li><a href='<txp:permlink />'><txp:title /></a>
<txp:if_article_id> THIS IS CURRENT </txp:if_article_id>
</li>
</txp:article_custom>
Just tried – even without id='<txp:article_id />'
tag works as it should, i think!
Last edited by the_ghost (2009-02-03 22:10:45)
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
Pages: 1