Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Exclude specific category from listing
I’m using an <txp:article_custom />
tag to list section’s articles.
I’de like to know if there’s the possibility to exclude from this list a specific category. The articles with that category will be grouped below to create a contextual menu adding a level of navigation.
Someone can help me?
Thanks
Offline
#2 2010-11-17 10:16:28
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Exclude specific category from listing
I was about to suggest smd_query but then I got another idea:
You could set a new txp variable this way:
<txp:variable name="my_categories" value="<txp:category_list wraptag='' break=',' exclude='cat_to_exclude' />" />
and then
<txp:article_custom category="<txp:variable name='my_categories' />" />
Note that this is just a quick’n‘dirty non-tested example (and I hope I’ve correctly nested quotes – I always get them wrong).
Last edited by redbot (2010-11-17 11:02:20)
Offline
Re: Exclude specific category from listing
You could list all the categories you want in the category attribute of the tag, minus the one(s) you want to exclude. But that would be rather bulky code. :)
Plus it would not update as you added or deleted categories.
For simplicity it might be nice if <txp:article_custom /> had the exclude attribute built in. Especially since the tag is designed to create custom output.
However, with tags in tags, it probably isn’t necessary as long as other tags use the exclude attribute.
In addition to redbot’s suggesion, would this also work?
<txp:article_custom category='<txp:category_list exclude="category_you_want_to_exclude" />' />Last edited by maverick (2010-11-17 14:29:51)
Offline
#4 2010-11-17 14:37:15
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Exclude specific category from listing
maverick wrote:
In addition to redbot’s suggesion, would this also work?
Yes, of couse you are right. My solution was too rushed ;-)
Offline
#5 2010-11-17 20:16:54
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Exclude specific category from listing
maverick wrote:
In addition to redbot’s suggesion, would this also work?
<txp:article_custom category='<txp:category_list exclude="category_you_want_to_exclude" />' />
Change that into
<txp:article_custom category='<txp:category_list exclude="category_you_want_to_exclude" break=","><txp:category /></txp:category_list>' />
or you will get hyperlinked categories, and don’t forget break=","
, or else it will use br
!
Offline
Re: Exclude specific category from listing
Thanks Els – I didn’t take time to test my code :)
Offline
Re: Exclude specific category from listing
the last time i had a go with this, the txp:category list script i was using was very long and wasn’t working. i keep wondering why they don’t just include an ‘exclude’ function.
Offline
Re: Exclude specific category from listing
Thanks to all!
Solved! Enable this option as attribuite is a must!
Offline