Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Display articles by category
I’m developing a website with a view sections but many categories (only one article per category). My page has an article tag <txp:article form="static_text" limit="1" />
and the form “static_text” looks as follows
<!-- Display section pages i.e. about -->
<txp:if_category name="">
<h3><txp:title /></h3>
<txp:body />
</txp:if_category>
<!-- Display category pages i.e. about?=quality-->
<txp:if_category name="quality">
<txp:article_custom category="quality">
<h3><txp:title /></h3>
<txp:body />
</txp:article_custom>
</txp:if_category>
<txp:if_category name="safety-hse">
<txp:article_custom category="safety-hse">
<h3><txp:title /></h3>
<txp:body />
</txp:article_custom>
</txp:if_category>
etc
The first part in the form is responsible to display articles without a category i.e. about (section). The next declarations show each article with a certain category name. It works but shouldn’t there be an easier way to declare the form content i.e. <txp:category />
instead of the written out category name for each category (tried this but won’t display the article), which ends up being a very long list and easy scalability is not given.
Any help would be much appreciated.
otti
Offline
Re: Display articles by category
You mean this does not work?
<txp:if_category>
<txp:article_custom category='<txp:category />'>
<h3><txp:title /></h3>
<txp:body />
</txp:article_custom>
<txp:else />
<h3><txp:title /></h3>
<txp:body />
</txp:if_category>
Offline
Re: Display articles by category
Thanks so much etc.
I think the doubling up of the category was the culprit. It’s working now with your help.
Many thnaks again.
otti
Offline
Pages: 1