Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-16 22:11:58

ndrwtrvrs
Member
From: London
Registered: 2008-04-03
Posts: 25
Website

Excluding articles based on a category being set

Hi all,

I’d like to be able to show specific articles on a page, based on a category not being set to a particular value – I suspect I’m going to have a moment of slapping hand to forehead, but how do I go about constructing an article form to do this?

To explain it a little further, I have a home page article that is shown when a category called ‘featured’ is set. I want to exclude all articles with a category of ‘featured’ appearing in a subsequent list of recent articles to avoid duplication.

You can see it here: http://byekick.com

Thanks in advance for your help…

Andrew

Offline

#2 2009-12-16 22:14:05

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

Re: Excluding articles based on a category being set

In the article form:

<txp:if_article_category name="featured">
<txp:else />
// content here
</txp:if_article_category>

Offline

#3 2009-12-16 22:29:43

ndrwtrvrs
Member
From: London
Registered: 2008-04-03
Posts: 25
Website

Re: Excluding articles based on a category being set

Els, that’s really helpful thanks – because I’ve been pulling through the articles that aren’t ‘featured’ by offsetting, so the if_article_category isn’t quite having the effect I need. The code currently looks like this:

<txp:if_article_category name="featured"> 
<txp:else />
<txp:article_custom form="journal.list" limit="1" offset="2" section="journal" />
</txp:if_article_category>

Any tips on a more efficient/effective way of doing this?

Thanks again!

Offline

#4 2009-12-16 22:36:13

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

Re: Excluding articles based on a category being set

I can’t imagine that is going to work…? Just add the if_article_category tags to your form ‘journal.list’ and remove the offset attribute from the article_custom tag.

Offline

#5 2009-12-16 23:54:45

ndrwtrvrs
Member
From: London
Registered: 2008-04-03
Posts: 25
Website

Re: Excluding articles based on a category being set

thanks again, Els! I need to have a bit of a think about how I’m pulling in each of the ‘recent’ (but not ‘featured’) articles in, but shifting the if_category conditional tag definitely improves things.

Offline

Board footer

Powered by FluxBB