Search code examples
phpmysqlsmarty

Next item in foreach SMARTY


I do slider on the website. On one slide I have two div. The data displayed on the SMARTY.

Slider div's

{foreach $slider as $sliderr}
    <div id="sliderBox">
<div id="showcase" class="showcase">
        <div class="showcase-slide">
            <div class="showcase-content">
{$sliderr.img}
            </div>
        </div>
        <div class="showcase-slide">
            <div class="showcase-content">
                {$sliderr.img} // ?? I need img+1
            </div>
        </div>  
</div>
</div>
{/foreach}

I need the next record from the table slider. How to read the next record SMARTY in a loop?


Solution

  • Maybe this works for you:

    {foreach from=$slider key=i item=sliderr}
        <div id="sliderBox">
    <div id="showcase" class="showcase">
            <div class="showcase-slide">
                <div class="showcase-content">
    {$sliderr.img}
                </div>
            </div>
            <div class="showcase-slide">
                <div class="showcase-content">
                    {$slider[{$i+1}]}
                </div>
            </div>  
    </div>
    </div>
    {/foreach}