Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-06-18 19:51:44

MattH
Member
From: Ann Arbor, MI
Registered: 2004-10-17
Posts: 30

Article_custom: exclude categories

I feel I’ve asked this before, years ago, but cannot find the source.

Is it possible to use the article_custom category attribute to exclude categories? That is, I’d like all articles that aren’t in a particular category.

Syntax might look something like: <article_custom category=”!cat1” … />

Offline

#2 2009-06-18 21:38:22

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Article_custom: exclude categories

<txp:article_custom category='<txp:category_list exclude="cat1" break=","><txp:category /></txp:category_list>' />

Offline

#3 2009-06-18 22:45:31

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: Article_custom: exclude categories

Damn, how much beauty is in uglyness =D)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2009-06-18 23:26:29

MattH
Member
From: Ann Arbor, MI
Registered: 2004-10-17
Posts: 30

Re: Article_custom: exclude categories

Yipes! But thanks, that’s a clever hack.

Offline

#5 2009-06-18 23:30:02

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Article_custom: exclude categories

MattH wrote:

that’s a clever hack.

That’s not a hack! It’s pure Txp :)

Offline

#6 2009-11-27 04:40:52

Rimfya
Member
Registered: 2007-11-22
Posts: 31

Re: Article_custom: exclude categories

I keep wondering this myself, and keep Googling’ up this thread. So here’s my solution I thought up. In the form, just place the following:

@<txp:if_article_category name=“whatever you want to exclude”><txp:else />*Whatever you want to display*</txp:if_article_category>

Last edited by Rimfya (2009-11-27 04:41:49)

Offline

#7 2009-11-27 05:10:53

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Article_custom: exclude categories

Rimfya wrote:

I keep wondering this myself, and keep Googling’ up this thread. So here’s my solution I thought up. In the form, just place the following:

<txp:if_article_category name=“whatever you want to exclude”><txp:else />Whatever you want to display</txp:if_article_category>

Why did you awake this old topic. Anyway, note that your code will filter results after articles have been pull out of the db. Which means that if you have lot of articles, it’s slow as hell. Plus you can’t use limit nor offset, as all the articles must be fetched for the after filter to work. Els’ solution beats every of those drawbacks.

Offline

#8 2010-01-12 15:13:51

tapaheh
New Member
Registered: 2009-12-17
Posts: 3

Re: Article_custom: exclude categories

Els wrote:

bc. <txp:article_custom category=’<txp:category_list exclude=“cat1” break=”,”><txp:category /></txp:category_list>’ />

However this solution doesn’t work if i have a category set for the articles i want to exclude and have no category for the rest of the articles.

Offline

#9 2010-09-10 03:02:33

mrtunes
Member
From: Toronto, On
Registered: 2007-03-12
Posts: 575
Website

Re: Article_custom: exclude categories

Why can’t exclude be an attribute in the article_custom tag?

Offline

#10 2010-09-10 10:21:03

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: Article_custom: exclude categories

@category_list@ has the exclude attribute. You could insert a category_list tag as the value of/into article_custom’s category attribute.
Edit: completely ignored in which topic I posted :p

Last edited by uli (2010-09-10 10:28:07)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB