We Recommend

Smarty PHP Template Programming And Applications Smarty PHP Template Programming And Applications
Smarty is a templating engine for PHP. Designers who are used to working with HTML files can work with Smarty templates, which are HTML files with simple tags while programmers work with the underlying PHP code. The Smarty engine brings the code and templates together. The result of all this is that designers can concentrate on designing, programmers can concentrate on programming, and they don't need to get in each others way so much.


Posted By

assbach on 02/16/07


Tagged

Smarty count counter lists


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

Bunker


several counters


Published in: Smarty 


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

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.


  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 />

Report this snippet 

You need to login to post a comment.