Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-11-09 02:01:27

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

two matching categories as article selection criteria

i need to make a selection criteria, which basically selects display of certain articles, because they belong to two certain categories, say “mr-bimsenstein” AND “red-hat”.

could anyone point me into the right direction, preferrably without using another plug?
thanx much!

EDIT: i guess i need be more explaining, following above example.

i am trying to get articles, which belong to both categories like this
in page
<txp:if_category name=“mr-bimsenstein”>
<txp:output_form form=“filter_another_cat” />
</txp:if_category>

in form “filter_another_cat”
<txp:article_custom section=“onesection” category=“red-hat”>

that doesn’t work.
displayed articles belong to the category in the form, but are not restricted by the page code, that calls it. hmm.. anyone?

Last edited by jayrope (2006-11-09 12:52:26)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#2 2006-11-09 18:06:41

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

Re: two matching categories as article selection criteria

Is ‘mr-bimsenstein’ always category1 and ‘red-hat’ always category2 (or the other way around of course)? In that case I think you can do it like this:

<txp:if_category name="mr-bimsenstein">
<txp:article listform="filter_another_cat" />
</txp:if_category>

Form ‘filter_another_cat’:

<txp:if_article_category number="2" name="red-hat">
<txp:title />
<txp:body />
</txp:if_article_category>

Offline

#3 2006-11-09 18:43:19

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: two matching categories as article selection criteria

Or you can filter out one of the categories by setting the category attribute in the article tag (faster because the filtering happens earlier, in MySQL). Doesn’t matter which is category1 and which is category2, if the only requirement is that both match.

<txp:article_custom form="filter_another_cat" category="mr-bimsenstein" />

Form ‘filter_another_cat’:

<txp:if_article_category name="red-hat">
  <txp:title />
  <txp:body />
</txp:if_article_category>

Last edited by ruud (2006-11-09 18:51:17)

Offline

#4 2006-11-09 20:50:59

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: two matching categories as article selection criteria

Both good ideas. Alternatively you might want to try the plug-in chh_article_custom which allows for category="this,that&mine" notation. There are some caveats: see the attribute ref page.

Last edited by jakob (2006-11-09 20:51:33)


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB