Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-12-29 09:21:48

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 276

How to add auto numbering in article list

I want to list top 3 articles and want to add automatic numbering with each title:


<txp:article_custom category="top" limit="5">
    <span class="number">{here come auto number}</span> : <txp:title />
</txp:article_custom>

Output Need:
1 : article title here
2 : article title here
3 : article title here

Last edited by raminrahimi (2022-12-29 09:54:57)

Offline

#2 2022-12-29 09:49:07

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

Re: How to add auto numbering in article list

Hi

Why not use CSS for that :

<ol>
<txp:article_custom category="top" limit="5">
    <li><txp:title /></li>
</txp:article_custom>
</ol>

Offline

#3 2022-12-29 09:56:14

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 276

Re: How to add auto numbering in article list

No, I want to use the numbering exactly in my template. The numbering is designed in the span <span class="number">...

Offline

#4 2022-12-29 10:54:23

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: How to add auto numbering in article list

You can either increment a variable

<txp:article_custom category="top" limit="5">
    <span class="number"><txp:variable name="count" add output /></span> : <txp:title />
</txp:article_custom>

or use the internal <txp:yield item="count" /> txp counter

<txp:article_custom category="top" limit="5">
    <span class="number"><txp:yield item="count" /></span> : <txp:title />
</txp:article_custom>

Offline

#5 2022-12-31 05:20:37

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 276

Re: How to add auto numbering in article list

etc wrote #334426:

You can either increment a variable

<txp:article_custom category="top" limit="5">...


Thanks, this works fine for me :-)

Offline

Board footer

Powered by FluxBB