Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How to exclude and/or match categories in article_custom tag?
The current documentation seems a bit vague on this, but how do you utilise the exclude
and/or match
for categories in a <txp:article_custom />
tag?
For example, if I have this (incorrect) code…
<h2>Featured themes</h2>
<txp:article_custom form="article_listing" section="themes" category="featured" exclude="admin" sort="custom_1" limit="8" wraptag="div" />
<h2>Featured admin themes</h2>
<txp:article_custom form="article_listing" section="themes" category="featured" match="admin" sort="custom_1" limit="2" wraptag="div" />
…I was guessing the category1 admin
would be excluded in tag 1 and matched in tag 2, but it doesn’t work. FYI ‘featured’ is only ever used as category2 if that makes any difference.
Any tips, once I know then I will update the docs with examples of how to use those attributes for categories.
Textpattern avengers, assemble! (please)
Offline
Re: How to exclude and/or match categories in article_custom tag?
Hmm, I don’t think one can separately filter by both categories, and exclude
accepts fields names, not values. If we had category1
and category2
attributes, this would work:
<h2>Featured themes</h2>
<txp:article_custom category2="featured" category1="admin" exclude="category2" form="article_listing" section="themes" sort="custom_1" limit="8" wraptag="div" />
<h2>Featured admin themes</h2>
<txp:article_custom category2="featured" category1="admin" form="article_listing" section="themes" sort="custom_1" limit="2" wraptag="div" />
Offline
Re: How to exclude and/or match categories in article_custom tag?
No, I’m wrong, there is a way, even two. If ‘admin’ is only used in Category1
and ‘featured’ only in Category2
<txp:article_custom match="category1, category2" category="featured, admin" exclude="category2" ... />
should work, matching
Category1 IN('featured','admin') AND Category2 NOT IN('featured','admin')
Or you can decide to fetch categories from URL variables, say c1
and c2
:
<txp:article_custom match="category1=c1, category2=c2" exclude="category2" ... />
Then ?c1=admin&c2=featured
URL should match
Category1 IN('admin') AND Category2 NOT IN('featured')
Offline
Re: How to exclude and/or match categories in article_custom tag?
Thanks Oleg, I’ve tackled this a different, easier way now (2 separate sections) but your suggestions are helpful learning.
Offline