Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-03-01 22:09:37

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

filtering article lists

If i want to use only one section page but filter its article list (thumbnails) by categories what is the best way to do it? I mean if the section landing displays all the articles in that section but then there are options to display only articles in certain categories where would i start?
Can anyone point me in a direction for what tags i should be looking at?
Thanks.

I was looking at true_tags and also wet_thumbfilter. But want to use categories if possible…


its a bad hen that wont scratch itself.
photogallery

Offline

#2 2011-03-01 22:49:40

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: filtering article lists

If you are using txp:article, it should be context-sensitive and output only the articles belonging to a category if the current page is a category list.

If you want more fine-grain control, you can use txp:if_category in your page template to tell txp how to display articles when viewing a category listing (see example 3 in the linked-to article). You should also be able to use txp:article_custom category='<txp:category />' ... if you want to use article_custom to output articles from the current category as given in the url… In short, you don’t need a plugin for this.


TXP Builders – finely-crafted code, design and txp

Online

#3 2011-03-01 23:05:59

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: filtering article lists

Hi well could I use the if_category for multiple criteria though. I mean would something like this be good?

<txp:if_category name=“filter1”> display list of filter1 articles
<txp:else />
<txp:if_category name=“filter2”> display list of filter2 articles
<txp:else />
<txp:if_category name=“filter3”> display list of filter3 articles
<txp:else /> display full list
</txp:if_category>


its a bad hen that wont scratch itself.
photogallery

Offline

#4 2011-03-01 23:46:23

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

Re: filtering article lists

You don’t need that. If you’ve got a <txp:article /> tag on the page, articles from the right category will be displayed when pages like /section-name/?c=category-name are requested. Use the section attribute in the category_list tag to display the category pages on the section page:

<txp:category_list categories="filter1,filter2,filter3" section="section-name" />

Offline

#5 2011-03-01 23:49:24

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

Re: filtering article lists

Oh, and if you need to nest conditional tags, do this:

<txp:if_category name="1">
   something
<txp:else />
   <txp:if_category name="2">
      something else
   <txp:else />
      <txp:if_category name="3">
         blah
      </txp:if_category>
   </txp:if_category>
</txp:if_category>

Offline

#6 2011-03-01 23:59:14

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: filtering article lists

ahh.. thanks.


its a bad hen that wont scratch itself.
photogallery

Offline

#7 2011-03-02 16:22:41

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: filtering article lists

right ok,

……

Any opinions on the above gallery navigation that I’ve put together with your help.
Obviously it’s getting confusing, but I think it requires the category filtering because there will be a large number of thumbs for each section.

Last edited by kvnmcwebn (2011-03-02 23:16:48)


its a bad hen that wont scratch itself.
photogallery

Offline

#8 2011-03-02 20:50:59

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

Re: filtering article lists

The only thing that might be confusing is that when using the prev/next links, you lose the category context. Personally I don’t mind that, but that may be because I understand how it works ;) I can’t remember if smd_horizon lets you navigate inside categories, but you could have a look.

(Whoa, nice one ;) )

Last edited by els (2011-03-02 20:52:25)

Offline

#9 2011-03-02 22:40:25

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: filtering article lists

exactly els,
i was just working on how to handle that…
The only thing i came up with was using if category to turn off the prev/next tags altogether inside the category filtered list.

I’ll check out smd horizon

thanks a million for taking a look.


its a bad hen that wont scratch itself.
photogallery

Offline

#10 2011-03-02 22:41:21

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: filtering article lists

El’s wrote:
(Whoa, nice one ;) )

ha ha ha i know.


its a bad hen that wont scratch itself.
photogallery

Offline

Board footer

Powered by FluxBB