Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Display articles only with empty category
This seems like a question from 2004 but…
I want to use txp:article
but exclude one particular category. So, everything but CatX.
Obvs, I could use txp:if_article_category
but I want to page through normally.
What am I missing?
Offline
Re: Display articles only with empty category
Would the snippet below work?
<txp:article>
<txp:if_article_category name="CatX" not>
do something
</txp:if_article_category>
</txp:article>
Yiannis
——————————
neme.org | hblack.net | EMAP | A Sea change | NeMe @ github
I do my best editing after I click on the submit button.
Offline
Offline
Re: Display articles only with empty category
etc wrote #328501:
Just say it:
<txp:article exclude category="CatX" />...
Where is the like button:)
Yiannis
——————————
neme.org | hblack.net | EMAP | A Sea change | NeMe @ github
I do my best editing after I click on the submit button.
Offline
Re: Display articles only with empty category
Here it is Yiannis ;)
👍
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Display articles only with empty category
etc wrote #328501:
Just say it:
<txp:article exclude category="CatX" />...
Oh, I wish. But txp:article exclude
doesn’t work that way
I can do <txp:article exclude = 'category2' />
and all articles that have an article category 2 will be excluded. But It won’t exclude a specific category.
Offline
Re: Display articles only with empty category
colak wrote #328500:
Would the snippet below work?
<txp:article>
<txp:if_article_category name="CatX" not>
do something
</txp:if_article_category>
</txp:article>
THANK you for introducing me to that parameter not
. Wonderful – but also undocumented.
This snippet works fine for excluding CatX – but it can mess up the normal pagination of txp:article.
Imagine you have 100 articles. The first 5 are tagged ‘CatX’ then 20 that are not, then 50 that are.
If you page through your articles using <older><newer>, the first page will only have five articles, the next two will be fine, then the viewer will have five blank pages before coming to articles again.
Offline
Offline
Re: Display articles only with empty category
What is txp version you have tested?
4.8.4
Offline
Re: Display articles only with empty category
Ah yes, you are right, <txp:article />
does not accept category
attribute (<txp:article_custom />
does). That’s annoying, but this tag was engineered like this, it inherits its category from URL. Scratching head…
Offline
Re: Display articles only with empty category
Not ideal, but you can do it in two passes:
<txp:variable name="ids">
<txp:article_custom exclude category="catx" fields="thisid" break="," limit="999">
<txp:article_id />
</txp:article_custom>
</txp:variable>
<txp:article id='<txp:variable name="ids" />' />
Offline
Re: Display articles only with empty category
etc wrote #328511:
Not ideal, but you can do it in two passes:
<txp:variable name="ids">...
Hey, that worked! Thank you.
Offline