Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Append numbers to articles
Hi! I want to append numbers from 1 to 10 to articles shown in result page.
Something like this:
<div class="article1"></div>
<div class="article2"></div>
<div class="article3"></div>
<div class="article4"></div>
.
.
.
Any ideas how could I achieve that?
Thanks in advance.
Last edited by robhert (2013-12-30 02:45:12)
Offline
Re: Append numbers to articles
I want to append numbers from 1 to 10 to articles shown in result page.
Wrap your articles in an ordered list.
In your page,
<txp:article listform=“article_listing” limit=“10” wraptag=“ol” />
In your form titled ‘article_listing’,
<li><txp:title /></li>
That will create an order list of maximum 10 articles displaying the title of each article. Like so.
<ol>
<li>1st Article Title</li>
<li>Second Article Title</li>
<li>Third Article Title</li>
</ol>
By default, without any CSS this will show numbers in order of 1 -10.
PS, If you’re using a template you may want to check the default CSS for ‘ol’ often set not to display the numerical value.
<txp:carver category="stone" type="hard"> These bits are harder than Basalt </txp:carver>
Offline
Re: Append numbers to articles
Hi robhert,
What will the divs contain?
Does it need to be 1-10? You could use the article_id or image_id for example.
Alternatively I’m sure there a php way of doing what you need:)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Append numbers to articles
Thank you guys for your replies!
In fact, what I do need is to append numbers to containers who wrap articles, like this way:
<txp:article_custom section="music" limit="10">
<div class="article-n">
<txp:title />
<txp:excerpt />
</div>
</txp:article_custom>
And the output should be:
<div class="article-1">
Title
Excerpt
</div>
<div class="article-2">
Title
Excerpt
</div>
<div class="article-3">
Title
Excerpt
</div>
...
As you may see, it is necessary to have control over the appended numbers to apply different CSS styles (from article-1 to article-10)
I can’t use ordered list (ol), because I think I wouldn’t get what I want.
Yep, maybe PHP would make the trick, but, sadly I don’t know how to do it.
Any ideas, would be appreciate.
Thank in advance.
Offline
#5 2013-12-30 14:52:56
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: Append numbers to articles
Hi Robhert,
there’s a variant of Ruud’s rvm_counter that handles increments completely in memory. Replace the entire content of Ruud’s plugin with the linked code. Edit: The plugin help will still be valid except for storage in “txp_discuss_nonce”
Last edited by uli (2013-12-30 15:02:15)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Append numbers to articles
Hi uli! Thank you!
I get this error, just installed the modified plugin
Parse error: syntax error, unexpected ‘.’ in /public_html/textpattern/lib/txplib_misc.php(812) : eval()’d code on line 1
Los errores anteriores los ha causado el plugin:rvm_counter
Any idea?
Offline
#7 2013-12-30 15:42:51
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: Append numbers to articles
robhert wrote #277663:
unexpected ‘.’
You probably grabbed the c..
prefix. Remove it so the code starts with function
.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Append numbers to articles
Yeap! Your are right. Now it works as expected!!! Thank you Uli.
Offline
Pages: 1