Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-10-05 15:02:40

Katalonian
Member
From: Baku, Azerbaijan
Registered: 2010-04-18
Posts: 219
Website

comma-separated categories

Hi guys.
I want to view article, which placed in two categories, but, i dont want to show articles, which placed in one of categories also.

for example, i want to show one article, which placed in category a and b, i do for it:

<txp:article_custom category=“a, b” form=“default” limit=“3” pgonly=“0” section=“news” sort=“Posted desc” status=“4” />

TXP views all articles which placed in both categories, but i have only one article which is placed in both categories. How i can do this?
thanks.


<txp:txp_me />

Offline

#2 2010-10-06 09:00:04

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,549
Website GitHub Twitter

Re: comma-separated categories

Hi Zia

I dont know how you can do that usi,g standard txp tag, the only way isee is by using bloke pluggin : smd_query

Cheers

Offline

#3 2010-10-07 15:52:02

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: comma-separated categories

soo_article_filter is another possible solution.

<txp:soo_article_filter where="category1 IN ('a','b') AND category2 IN ('a','b')">
<txp:article_custom limit="3" section="news" />
</txp:soo_article_filter>

Notes:

  • This is untested.
  • The category test I’ve used here isn’t very strict; it only checks that each article category is assigned to either ‘a’ or ‘b’. To get something more specific would require a more elaborate where clause.
  • I’ve removed the unneeded attributes from your article_custom tag. You have three (status, sort, form) that you are simply setting to their default values, and one (pgonly) that doesn’t do anything in article_custom (it’s allowed because of the shared code between article and article_custom).

Code is topiary

Offline

Board footer

Powered by FluxBB