Answer the question
In order to leave comments, you need to log in
yii2 listview. How to insert a block after every 3rd element (item)?
Can you tell me how to make it possible to insert a block through every 3rd element. The picture shows where it should be. How can I do it? Thanks in advance.
Answer the question
In order to leave comments, you need to log in
<?= ListView::widget([
'dataProvider' => $dataProvider,
'itemOptions' => ['tag' => false],
//'itemView' => '_teaser',
'itemView' => function ($model, $key, $index, $widget) {
return $this->render('_teaser', [
'model' => $model,
'key' => $key,
'index' => $index,
'widget' => $widget,
]);
}
]) ?>
<div class="item" data-key="<?=$model->id?>">
...
</div>
<?php if (($index+1) % 3 == 0) : ?>
я после третьего?
<?php endif; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question