Next item in foreach SMARTY

2019-08-08 20:48发布

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?

标签: php mysql smarty
1条回答
霸刀☆藐视天下
2楼-- · 2019-08-08 21:51

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}
查看更多
登录 后发表回答