Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-02-14 09:03:16
- dandul
- Member
- From: Brisbane, Australia
- Registered: 2010-01-31
- Posts: 33
article_custom tag - can it exclude the current section's articles?
Hi, I’m trying to set up a sidebar that will list all the articles on the website except for the articles in the section I’m currently viewing.
So let’s say I have three sections – One, Two, Three. If I’m in One, the side bar will list the articles for Two and Three. If I’m in Two the side bar will list the articles in One and Three and so on.
I’ve got as far as using custom_article to generate a list of article titles.
<txp:article_custom form=“simpl_title” sort=“title” break=“br”/>
Is it possible to exclude one section from this? And instead of naming a specific section is it possible to make it dynamic so TXP automatically excludes the current section?
I had a dream it would be as easy as this: <txp:article_custom section_exclude=“current” />
Sorry if this has been answered elsewhere, i looked around and found nowt.
Thanks. This is my first question but the forum has already given me lots of answers!
Stop wishing things were different to the way they are. Accept it, deal with it, move on.
Offline
Offline
#3 2010-02-14 11:28:21
- Bongo-man
- Member
- Registered: 2009-03-18
- Posts: 243
Re: article_custom tag - can it exclude the current section's articles?
I’m also interested in this issue. I’ve something a little similar.
In my case I need to prevent the url_title of the current article be displayed in the matching page, among those of the same category randomly listed (1 for page) at the bottom of each page.
To get the link at the bottom of the page I use:
<txp:article_custom category=’<txp:category1 />’ section=“x, y, z, t” sort=“rand()” limit=“1”> <txp:permlink><txp:title /></txp:permlink></txp:article_custom>
Offline
Re: article_custom tag - can it exclude the current section's articles?
Not too elegant, but this should work:
<txp:variable name="this_id" value='<txp:article_id />' />
<txp:article_custom limit="2" sort="rand()">
<txp:if_article_id id='<txp:variable name="this_id" />'>
<txp:else />
<txp:if_variable name="done">
<txp:else />
<txp:permlink><txp:title /></txp:permlink>
<txp:variable name="done" value="" />
</txp:if_variable>
</txp:if_article_id>
</txp:article_custom>
That is, set a variable
to the current article’s ID, then select 2 articles instead of 1, just in case you get the current article again.
Code is topiary
Offline
#5 2010-02-14 21:19:08
- Bongo-man
- Member
- Registered: 2009-03-18
- Posts: 243
Re: article_custom tag - can it exclude the current section's articles?
Thank you, I will try to use this expression.
Another little question: I’ve seen you have put a limit=“2” to the displaying of random permalinks.
Do the random attribute slow the database whether the limit is more than 2?
Thanks
Last edited by Bongo-man (2010-02-14 21:19:27)
Offline
Re: article_custom tag - can it exclude the current section's articles?
Bongo-man wrote:
Do the random attribute slow the database whether the limit is more than 2?
I gather that there are performance concerns with ORDER BY RAND()
in MySQL, but unless you have an unusually large textpattern table I doubt you will find this to be an issue, whatever the limit.
Code is topiary
Offline
#7 2010-02-17 11:19:55
- Bongo-man
- Member
- Registered: 2009-03-18
- Posts: 243
Re: article_custom tag - can it exclude the current section's articles?
ok, I thank you all.
Offline
#8 2010-02-19 02:50:13
- dandul
- Member
- From: Brisbane, Australia
- Registered: 2010-01-31
- Posts: 33
Re: article_custom tag - can it exclude the current section's articles?
Thanks very much, sorted that out nicely!
Stop wishing things were different to the way they are. Accept it, deal with it, move on.
Offline