Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-06-05 18:38:52

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

How to use exclude parameter in txp:article for excluding a category?

Since 4.6.0+ txp:article seems to support excluding articles by their category, but it is not really clear for me, how to realize that.

exclude="article id(s) or field(s)" v4.6.0+
    Exclude a specific article or list of articles (each ID separated by a comma), or the articles with matching fields (author, category, etc.).

So how can I exclude all articles with the first category “badcategory”?
Something like exclude="category=badcategory" doesn’t work.

<txp:article exclude="category1=badcategory" wraptag="" break="" offset="0" limit="12" />

exclude="field(category1,badcategory)" also doesn’t give the desired result.

Any hint?

Last edited by whocarez (2021-06-05 18:39:36)

Offline

#2 2021-06-05 18:48:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: How to use exclude parameter in txp:article for excluding a category?

Untested but have you tried:

<txp:article exclude="category1" category1="badcategory" wraptag="" break="" offset="0" limit="12" />

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2021-06-05 19:00:36

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: How to use exclude parameter in txp:article for excluding a category?

Unfortunately, that doesn’t work. Excludes a lot of articles, but not the right ones. It seems to exclude all articles with an existing category1, means shows only noncategorised articles.

Last edited by whocarez (2021-06-05 19:03:16)

Offline

#4 2021-06-05 21:15:10

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: How to use exclude parameter in txp:article for excluding a category?

How about

<txp:article exclude="category" category="badcategory" match="category1" />

Offline

#5 2021-06-06 08:22:00

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: How to use exclude parameter in txp:article for excluding a category?

Sadly, it doesn’t work. To be sure, I try that in Textpattern 4.8.7 with PHP 8.0.5.

Offline

#6 2021-06-06 09:16:25

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: How to use exclude parameter in txp:article for excluding a category?

It should probably be <txp:article_custom />, since <txp:article /> ignores category attribute.

Offline

#7 2021-06-07 13:14:08

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: How to use exclude parameter in txp:article for excluding a category?

Should we accept section, category, etc in <txp:article /> too, using URL context as defaults? Looks reasonable.

Offline

#8 2021-06-07 13:52:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,269
Website GitHub

Re: How to use exclude parameter in txp:article for excluding a category?

Seems like a good idea. Maybe one day article_custom can be retired.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB