Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-03-19 17:37:45

draganbabic
Member
From: Novi Sad, Serbia
Registered: 2006-09-27
Posts: 118
Website

Output the article's number in an article list wrapped in a span

This is a somewhat specific request – I need the following functionality and I’m wondering how to get it:

- All my article forms are inside <li> elements
- I am using article_custom to form an ordered list of articles and need to output a bit of code into every article, like so:

<li>
<!-- PHP should output this --><span class="sRank">1</span>
... other article stuff ...
</li>
<li>
<!-- PHP should output this --><span class="sRank">2</span>
... other article stuff ...
</li>
<li>
<!-- PHP should output this --><span class="sRank">3</span>
... other article stuff ...
</li>
...

So basically I need the code that would output the article’s number in that article list wrapped in a span.

Offline

#2 2008-03-19 17:48:03

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Output the article's number in an article list wrapped in a span

You can output the article id with <txp:article_id />, is that what you’re looking for?

Offline

#3 2008-03-19 17:55:49

draganbabic
Member
From: Novi Sad, Serbia
Registered: 2006-09-27
Posts: 118
Website

Re: Output the article's number in an article list wrapped in a span

Nah, I need the articles number in that list it is being output into.

Imagine if you have an ordered HTML list:

1. this is the first article in the list, it should contain <span class="sRank">1</span>
2. this is the second article in the list, it should contain <span class="sRank">2</span>
3. this is the third article in the list, it should contain <span class="sRank">3</span>
...

Hope this explains it a bit better…

Offline

#4 2008-03-19 20:14:30

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Output the article's number in an article list wrapped in a span

I’ve put this in the article form for the incrementing number before:

<txp:php>global $i;$i++;echo $i;</txp:php>

TXP Builders – finely-crafted code, design and txp

Offline

#5 2008-03-19 21:17:42

draganbabic
Member
From: Novi Sad, Serbia
Registered: 2006-09-27
Posts: 118
Website

Re: Output the article's number in an article list wrapped in a span

Thanks jakob, that did the trick!

Offline

#6 2008-03-19 23:37:03

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: Output the article's number in an article list wrapped in a span

in the meantime I discovered by chance that ruud made something nicer for this: rvm_counter.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB