Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-07-25 09:46:20

kevinmcdougall
Member
Registered: 2007-02-08
Posts: 55

How Do I Display Articles Filtered By Section & Cat1 & Cat2?

Hi, hoping someone can help me out with this.

I want to be able to filter articles by both Category_1 and Category_2, ie. I have a set of articles in a section which have an associated “Level” category (eg. A,B,C) AND an associated “Cost” category (eg. 1,2,3), how would I get TXP to display say, the articles only in Level “A” and Cost “2”? Ideally using a form with two select boxes? Or at worst, nested links.

Any help would be hugely appreciated.

Offline

#2 2007-07-25 22:37:16

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: How Do I Display Articles Filtered By Section & Cat1 & Cat2?

chh_article_custom

(article_custom only supports 1 category at present.)

Offline

#3 2007-07-27 13:25:01

kevinmcdougall
Member
Registered: 2007-02-08
Posts: 55

Re: How Do I Display Articles Filtered By Section & Cat1 & Cat2?

Thanks Mary, I did think that would do the job, but can’t for the life of me figure out how to build the HTML form and the TXP forms to handle what is pretty much a search query.

Offline

#4 2007-07-27 13:42:43

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

Re: How Do I Display Articles Filtered By Section & Cat1 & Cat2?

kevin, I managed to do this before, but it was rather complex. I described it in this thread. If you can’t follow that, e-mail me and I’ll see what I can do.

Last edited by jakob (2007-07-27 13:46:07)


TXP Builders – finely-crafted code, design and txp

Offline

#5 2007-07-27 15:54:17

kevinmcdougall
Member
Registered: 2007-02-08
Posts: 55

Re: How Do I Display Articles Filtered By Section & Cat1 & Cat2?

You’re a legend jakob! Definitely looks the part, but no time to have a look at it today. I’ve actually abandoned using this approach for the website I wanted to use this on, but have puzzled over this before and it will no doubt come in handy at some point, so I’m still delighted that you posted the link.

The articles now need to have 4-5 categories each so I decided to make dropdown custom fields instead and muck about with the TXP search to use it as the filter since I don’t anticipate it will ever be needed elsewhere on the site.

I know improving the search function has been mentioned elsewhere, but extending/specifying the scope of the search would be on my wishlist, especially and ideally if it could optionally (eg. fields=“Title,Keywords,Custom_1” and/or meta=“1” whatever) search other fields for article metadata such as custom fields or keywords.

Anyhoo, I’ll be experimenting with your method nonetheless, so thanks again.

Offline

#6 2008-01-31 18:31:19

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: How Do I Display Articles Filtered By Section & Cat1 & Cat2?

I was thinking about this today and had an idea…

What if you used a custom field instead of a 2nd category?
The <txp:article /> tag allows you to filter articles by a custom field’s value with customfieldname="value".

Since we now have Gerhard’s wonderful glz_custom_fields you could built a custom field with a drop-down selector of pre-defined choices to sort of “fake” a category selector.

Wouldn’t that work?

Cheers Martin

Last edited by masa (2008-01-31 18:32:08)

Offline

Board footer

Powered by FluxBB