several counters


/ Published in: Smarty
Save to your folder(s)

I used this for a numbered FAQ list. To be flexible when answers are taken out or moved in position or put in between... you don't have to worry about the numbers, cause they are dynamically parsed this way.

3 counters used in example here.


Copy this code and paste it in your HTML
  1. <ol>
  2. <li><a href="#{counter name=list start=1}">bla</a></li>
  3. <li><a href="#{counter name=list}">bla</a></li>
  4. <li><a href="#{counter name=list}">bla</a></li>
  5.  
  6. </ol>
  7.  
  8. <a name="{counter name=anchors start=1}"></a>
  9. <p><div class="num">{counter name=answers}</div><h3>bla</h3></p>
  10. <p>answer</p><hr />
  11.  
  12. <a name="{counter name=anchors}"></a>
  13. <p><div class="num">{counter name=answers}</div><h3>bla</h3></p>
  14. <p>answer</p><hr />
  15.  
  16. <a name="{counter name=anchors }"></a>
  17. <p><div class="num">{counter name=answers}</div><h3>bla</h3></p>
  18. <p>answer</p><hr />

URL: http://smarty.php.net/manual/de/language.function.counter.php

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.