Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: How to highlight article title ... !?
erronious = erroneous
Not only your code is … ;-)
Offline
Re: How to highlight article title ... !?
The if_first_article and if_last_article trick isn’t really needed (or am I missing something?):
So this:
<txp:article_custom>
<txp:if_first_article><ul></txp:if_first_article>
<li<txp:if_article_id> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
<txp:if_last_article></ul></txp:if_last_article>
</txp:article_custom>
can just be this:
<txp:article_custom wraptag="ul">
<li<txp:if_article_id> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
Last edited by maniqui (2009-04-13 15:46:53)
Offline
#18 2009-04-13 20:37:05
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to highlight article title ... !?
maniqui wrote:
The
if_first_articleandif_last_articletrick isn’t really needed (or am I missing something?):
No, you didn’t miss anything, you’re right – as always :) It’s a left-over from the pre- wraptag era ;)
Offline
#19 2010-06-17 11:34:23
- fantasmo
- Member
- Registered: 2010-05-05
- Posts: 40
Re: How to highlight article title ... !?
Hi,
i want to do the same thing, but with randomly chosen related_articles (I put them after the text of a single article)
I thought this would be very easy and tried the following thing:
In the form for the single article view i have:
<txp:related_articles limit="3" sort="rand()" wraptag="ul" break="" form="related_article" />
And in the form “related_article” i have:
<li <txp:if_last_article>class="last"</txp:if_last_article>>
<h3><txp:permlink><txp:title /></txp:permlink></h3>
<txp:article_image />
</li>
I really don’t get, why it doesn’t work…it always writes the class=“last” to EVERY related article.
Can anybody help please?
Offline
#20 2010-06-17 13:49:15
- fantasmo
- Member
- Registered: 2010-05-05
- Posts: 40
Re: How to highlight article title ... !?
Now i found a VERY bad solution..i take related_articles two times. In my article form I wrote:
<ul>
<txp:related_articles limit="2" sort="rand()" break="" form="related_article" />
<txp:related_articles limit="1" sort="rand()" break="" form="related_article" class="last" />
</ul>
I didn’t get that “article_custom”- or “if_firs/last_article”-thing to work…:-(
Still any help is very appreciated.
Offline
#21 2010-06-17 23:27:25
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to highlight article title ... !?
fantasmo wrote:
…it always writes the class=“last” to EVERY related article.
Did you check if it works if you use something else than sort="rand()"? I wouldn’t be surprised if that is what’s causing the problem. offset doesn’t work with sort="rand()" either. It’s not like the query creates an article list in a random order and selects the first three, but rather it goes through the articles to select a random one three times. At least that’s how I imagine it works, I’m not a coder and I may be totally wrong ;)
As an alternative you can give zem_nth a try (though it might have the same problem).
Offline
Re: How to highlight article title ... !?
OK … and now this one:
The webpage > www.redfoxwebdesign.nl/new/info
So we have two lists of article titles of the same section with different categories, e.g. ‘inclusief’ and ‘optioneel’ …
The code >
<h4>Inclusief:</h4>
<txp:if_individual_article>
<txp:article_custom section="info" category="inclusief" sort="position asc" wraptag="ol" class="titles">
<li<txp:if_article_id> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
<txp:else />
<txp:article_custom section="info" category="inclusief" sort="position asc" wraptag="ol" class="titles">
<li<txp:if_first_article> class="active"</txp:if_first_article>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
</txp:if_individual_article>
<h4>Optioneel:</h4>
<txp:if_individual_article>
<txp:article_custom section="info" category="optioneel" sort="position asc" wraptag="ol" class="titles">
<li<txp:if_article_id> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
<txp:else />
<txp:article_custom section="info" category="optioneel" sort="position asc" wraptag="ol" class="titles">
<li<txp:if_first_article> class="active"</txp:if_first_article>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
</txp:if_individual_article>
Because of this piece of code I get TWO highlighted article titles on the landing page. But that’s not what I want … I only want the article title highlighted of the (only) article on the landing page, e.g. ‘Teksten’ … !?
I tried all kind of things with several TXP tags (if_article_category; if_category; etc.) but with no success. Any help is appreciated!
Last edited by RedFox (2010-07-19 19:49:35)
Offline
#23 2010-07-19 22:07:08
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to highlight article title ... !?
…maar wel met een hele grote strik!
LOL!
If the landing page article is always the first one in the ‘Optioneel’ menu, I think you only need to remove the <txp:if_first_article> class="active"</txp:if_first_article> in the ‘Inclusief’ menu…
Offline
Re: How to highlight article title ... !?
Eh, no, although there will not be very many new articles, they will come sooner or later. And it can be an article in ‘Inclusief’ or ‘Optioneel’ … so, what to do … !?
Offline
#25 2010-07-20 15:23:27
- GugUser
- Member

- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,477
Re: How to highlight article title ... !?
What is “info” in the URL (www.redfoxwebdesign.nl/new/info)? An article?
Offline
#26 2010-07-20 17:26:46
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to highlight article title ... !?
RedFox wrote:
Eh, no, although there will not be very many new articles, they will come sooner or later. And it can be an article in ‘Inclusief’ or ‘Optioneel’ … so, what to do … !?
So are you always showing the most recent article on the landing page then? I’m trying to find out how you determine which article appears on the landing page, you need to know what to check for to find out which conditional to use.
Edit: I may have an idea, but I think it can only work if the sort order of the articles in the side menu is the same as the sort order in your article tag in the main content.
@GugUser: ‘info’ is a section.
Edit again: I think I found it! What is your article tag to display the article on the landing page?
Last edited by els (2010-07-20 17:47:28)
Offline
Re: How to highlight article title ... !?
The article tag > <txp:article limit="1" form="singleplus" sort="position asc" />
I’m using sort=“position asc” because of stm_article_order … so I can sort the articles as I wish … and that could change by the day!
Offline
#28 2010-07-20 19:27:42
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to highlight article title ... !?
Code edited to replace category1 (d’oh!) with category…
OK, I’m not 100% certain it will work, but could you give this a try?
<txp:category_list categories="inclusief,optioneel" break="">
<h4><txp:category title="1" /></h4>
<txp:if_individual_article>
<txp:article_custom section="info" category='<txp:category />' sort="position asc" wraptag="ol" class="titles">
<li<txp:if_article_id> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
<txp:else />
<txp:article_custom section="info" category='<txp:category />' sort="position asc" wraptag="ol" class="titles">
<li<txp:if_article_id id='<txp:article_custom section="info" limit="1" sort="position asc"><txp:article_id /></txp:article_custom>'> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
</txp:if_individual_article>
</txp:category_list>
I’m not sure if the txp:article_custom tag inside the id attribute can be replaced by <txp:article limit="1" sort="position asc">, you could try that as well.
Last edited by els (2010-07-20 20:11:57)
Offline
Re: How to highlight article title ... !?
And the results are:
“Tag foutmelding <txp:category1 title=“1” /> -> Textpattern Notice: Artikel tags kunnen niet buiten hun eigen context gebruikt worden on line 2175” (2x)
With <txp:article limit="1" sort="position asc"> the results are:
“Tag foutmelding <txp:category1 title=“1” /> -> Textpattern Notice: Artikel tags kunnen niet buiten hun eigen context gebruikt worden on line 2175” (2x)
With the same visual context >

So … it works! You’re great … only we have tag errors and there are empty <h4>‘s!
Last edited by RedFox (2010-07-20 19:41:16)
Offline
#30 2010-07-20 19:43:18
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to highlight article title ... !?
Ah of course. Sorry! One minute please…
D’oh! The category1 was a left-over from an earlier experiment… Try changing it to <txp:category>.
Last edited by els (2010-07-20 19:44:44)
Offline