Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#2 2009-11-02 10:17:49

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,538
Website GitHub Twitter

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

#3 2009-11-02 11:54:37

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

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

#6 2009-11-02 12:11:07

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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>

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

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

Board footer

Powered by FluxBB