Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2023-08-23 12:07:01

Registered: 2006-10-08
Posts: 1,300

Create article list grouped by month

guys, i need your help to create article list grouped by month. i stuck myself…

display all articles in section ‘‘events 2023’‘ grouped by month. desired output should be:

article1, article2, article3…

article4, article5, article6…

article7, article8, article9…

my current code:

<div class="title">
<h1><txp:title /></h1>
<p class="posted"><txp:posted format="%d.%m.%Y" /></p>
<div class="body">
<txp:body />

<txp:else />

<txp:category_list parent='<txp:section />' exclude='<txp:section />'>
<txp:if_different><txp:category title="1" wraptag="h4" /></txp:if_different>
<txp:article frontpage="0" limit="12" sort="Posted desc" wraptag="div" break="div" class="tulbad-4 tulbad-50 col-content-2">
<div class="article-img-2">
<txp:permlink><txp:article_image /></txp:permlink>
<txp:else />
<txp:images id="8,5" limit="1" sort="rand()" />
<div class="clock"><span class="posted">
<txp:if_custom_field name="kuupäev"><txp:custom_field name="kuupäev" /></txp:if_custom_field>
<h2><txp:permlink><txp:title /></txp:permlink></h2>
<txp:if_excerpt><txp:excerpt /></txp:if_excerpt>


and current output
duplicates all articles under all categories :(


#2 2023-08-23 12:22:18

From: Germany
Registered: 2005-01-20
Posts: 4,628

Re: Create article list grouped by month

I’m not sure how your categories feature in this, but essentially an article list grouped by month is a regular chronological list of articles with month/year headings inserted at the right points. For that you can use:

    <txp:posted format="%B %Y" wraptag="h3" />

within your article_list form or code as shown in this txptip.

If you need to do more complex wrapping of the articles in each month group, see this thread for a similar discussion.

TXP Builders – finely-crafted code, design and txp


Board footer

Powered by FluxBB