Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
article_id formatting
Hello,
I’d like to show my article ID# on my blog in a three-figure format, e.g. 001, 002, 076. Is there a way?
The first idea that came to mind was using an if/else on articles with IDs under 10 having two zeros ahead of the <txp:article_id /> in the form, or articles 10-99 having one zero, if that’s doable with some txp code I can’t find elsewhere.
Help?
Thanks!
Offline
Re: article_id formatting
<txp:php>
printf("%03d", article_id());
</txp:php>
Offline
Re: article_id formatting
Thanks JM! I put that in the form, which worked a treat. Is there somewhere else I can put it instead to make it site-universal? I somewhat new-ish to TextPattern.
Offline
Re: article_id formatting
You could create an article form called “post_id” containing the code I posted, and then in your default form (or whatever you’re using), use the following:
<h2>Post ID: <txp:output_form form="post_id"/></h2>
Offline
Re: article_id formatting
Thank you.
Offline
Pages: 1