Skip to content

What <each> does ​

The <each> tag is used in .html templates to iterate arrays—similar to PHP foreach.

Prepare data in the controller ​

app/home/controller/index.php:

php
class index{
    function docs (){
        $list = m('docs')->field('id,fid,title,sort')->order('id')->select();
        assign('list', $list);
        v();
    }
}

Template usage ​

app/home/view/index/docs.html:

html
<each "$list as $v">
    {$v['id']} - {$v['title']} 
</each>

Sample output ​

html
1 - Built-in tags
2 - Transactions
3 - Views

PhpTide documentation