Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
Re: Output the article's number in an article list wrapped in a span
Thanks jakob, that did the trick!
Offline
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