Search code examples
phpsmartycountertemplate-engine

Issues with .TPL file with Smarty


I use PHP Melody on my site and I don't know how can I make one thing.

I have this code to print on index 30 post:

Code:

{get_advanced_video_list assignto="new_videos" limit="30"}  
{foreach from=$new_videos key=k item=video_data}

I need after 5 post to put a div (div class="thumb-holder")

So there should be:

>div class="thumb-holder" post 1 post 2 post 3 post 4 post 5 /div><br>
>div class="thumb-holder" post6 post7 post8 post9 post10 /div><br>
>div class="thumb-holder" post11 post12 post13 post14 post15 /div><br>
>.........................<br>
>div class="thumb-holder" post26 post27 post28 post29 post30 /div <br>

I tried more things, but nothing has worked. What can I do?

PS: Is a .tpl file so outdated that it no longer works with PHP?


Solution

  • Here exactly what you wish:

    <div class="thumb-holder">
        {foreach from=$new_videos key=k item=video_data name=foo}
            {if $smarty.foreach.foo.index > 1 and $smarty.foreach.foo.index is div by 5}
                </div>
                <hr>
                <div class="thumb-holder">
            {/if}
            {$video_data}<br>
        {/foreach}
    </div>