Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-11-02 10:03:20
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
article list with category titles
again i can’t figure out myself. goal is to make article list with category titles they are associated. like this:
Category 1
- article 1 title link
- article 2 title link
Category 2
- article 3 title link
- article 4 title link
Category 3
- article 5 title link
- article 6 title link
etc.
Offline
Re: article list with category titles
Hi Gallex (ou salut ;) )
You can use something like this:
<txp:category_list>
<txp:category>
<txp:category link="1" />
<txp:article_custom category='<txp:category />'>
<p><txp:permlink><txp:title /></txp:permlink></p>
</txp:article_custom>
</txp:category>
</txp:category_list>
This only a global idea and not tested!
Offline
Re: article list with category titles
Interesting approach the one suggested by Dragondz.
Not sure why he suggest using a <txp:category></txp:category>
wrapping some code.
You may want to try this variation:
<txp:category_list>
<txp:if_different><h1><txp:category link="1" /></h1></txp:if_different>
<txp:article_custom category='<txp:category />' wraptag="ul" break="li">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:category_list>
That solution may be a little suboptimal because it’s querying the database for each category (ie. article_custom is run for each category).
The other more “common way” to do this is:
<txp:article> <!-- or article_custom -->
<txp:if_different><h1><txp:category1 /></h1></txp:if_different>
<p><txp:permlink><txp:title /></txp:permlink></p>
</txp:article>
The tricky part on this approach is getting the ul/li markup for each categorized list of articles.
You may want to take a look at this tutorial on creating a FAQ index by category.
Offline
#4 2009-11-02 11:55:20
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: article list with category titles
i modified dragondz code and get it work like i ment to be. thank you
and working code:
<txp:if_section name="maakonnad">
<txp:if_article_list>
<txp:category_list this_section="1">
<h6><txp:category title="1" /></h6>
<ul><txp:article_custom category='<txp:category />' form="article_b" limit="90" /></ul>
</txp:category_list>
<txp:else />
<txp:article />
</txp:if_article_list>
</txp:if_section>
Last edited by Gallex (2009-11-02 11:57:48)
Offline
#5 2009-11-02 12:07:22
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: article list with category titles
maniqui wrote:
<txp:category_list>
<txp:if_different><h1><txp:category link=“1” /></h1></txp:if_different>
<txp:article_custom category=’<txp:category />’ wraptag=“ul” break=“li”>
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:category_list>
tried your code maniqui too, but it doesn’t display individual articles
Offline
Re: article list with category titles
Oh, yes, that one was just to generate the list. You will also need to include some if_article_list magic, like you did on your previous post:
<txp:if_article_list>
<txp:category_list>
<txp:if_different><h1><txp:category link=“1” /></h1></txp:if_different>
<txp:article_custom category=’<txp:category />’ wraptag=“ul” break=“li”>
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:category_list>
<txp:else />
<txp:article />
</txp:if_article_list>
Offline
#7 2009-11-02 12:33:12
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: article list with category titles
i’ll use your solution cause it needs no extra form like mine. thank’s
Offline
Pages: 1