Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2007-10-24 13:27:24
- castanet
- Member
- From: Oxford
- Registered: 2005-03-19
- Posts: 97
Filtering articles by category
I am trying to display articles by category on an inside section.
The section ‘londonproperty’ uses <txp:article_custom form=“profile” category=“london” limit=“100”/> to show excerpts of all articles saved in the category ‘london’. (Each full article opens in the section ‘article’.)
I want visitors to be able to filter out the article excerpts to show just those from the sub-categories ‘northlondon’, ‘eastlondon’ etc etc.
So, at the side of the section’s page I put:
<ul> <txp:category wraptag=“li” link=1 title=1 name=“eastlondon” /> <txp:category wraptag=“li” link=1 title=1 name=“northlondon” /> </ul>
Further down the page I have:
<txp:if_category>
<txp:article form=“profile” limit=“100” />
<txp:else /><txp:article_custom form=“profile” category=“london” limit=“100”/>
</txp:if_category>
The category list shows, but the links won’t display the article excerpts in the same section.
What am I doing wrong?
Thanks in advance
Offline
Re: Filtering articles by category
What am I doing wrong?
<txp:article_custom />
isn’t content sensitive as <txp:article />
, so it will not change entries depending category. See:
Er – or:
The category list shows, but the links won’t display the article excerpts in the same section.
In the article- or londonproperty-section? Currently viewed? Try using <txp:category link="1" this_section="1" />
– it will show articles only in that section :-)
Cheers!
Last edited by Gocom (2007-10-24 14:23:44)
Offline
#3 2007-10-24 18:04:19
- castanet
- Member
- From: Oxford
- Registered: 2005-03-19
- Posts: 97
Re: Filtering articles by category
Thanks Gocom
<txp:article /> is what I have after <txp:if_category>
I tried using <txp:category link=“1” this_section=“1” /> but it doesn’t show the excerpts – just a blank page. Is it because the articles are saved in the section ‘article’ and I am trying to show the excerpts in the section ‘londonproperty’ ??
I am sure there’s a simple explanation – I just can’t see it at the moment!
Offline
Re: Filtering articles by category
Now I see. With help of plugin, asy_wondertag
At the section londonproperty:
<txp:if_section name="londonproperty">
<txp:if_category>
<txp:asy_wondertag>
<txp:article_custom section="article" category="<txp:c />" limit="100" form="profile" />
</txp:asy_wondertag>
</txp:if_category>
</txp:if_section>
It will display category-based articles from the article-section at londonproperty-section.
Cheers!
Offline
#5 2007-10-25 07:11:57
- castanet
- Member
- From: Oxford
- Registered: 2005-03-19
- Posts: 97
Re: Filtering articles by category
Bingo!
I had to move <txp:else /> and then adjust the tag nesting but this works:
<txp:if_section name=“londonproperty”> <txp:if_category> <txp:asy_wondertag> <txp:article_custom section=“article” category=”<txp:c />” limit=“100” form=“profile” /> </txp:asy_wondertag>
<txp:else /><txp:article_custom form=“profile” sort=“rand()” category=“london” allowoverride=“1” limit=“100”/>
</txp:if_category>
</txp:if_section>
Many thanks Gocom and thanks to Sencer for the plugin !
Offline
Pages: 1