Answer the question
In order to leave comments, you need to log in
How to display the views array in parts correctly?
I hang the site on the finished layout.
I'm theming views, and I have questions.
Layout in the form of columns. I display 9 news. They need to be arranged in 3 lines. So 3 news per line.
To split 9 news into 3 lines I use:
<?php foreach ($rows as $id => $row): ?>
<div class="four columns">
<div class="item">
<?php
$i++;
print $row;
if ($i == 3) {break;}
?>
</div>
</div>
<?php endforeach; ?>
Answer the question
In order to leave comments, you need to log in
It is worth simply initializing the variable $i = 0 before the loop, which will help to avoid the notice warning.
In views, you can do such tasks without temming with separate templates. If you need to group something, use Global: Custom text according to this principle
For the fields that you display in the global field, set Exclude from display and there will be no duplication.
For example, this view outputs
I'm using bootstrap, so the table doesn't fit so use Format:HTML list. This will suit you better too, since you can set your own classes:
In extreme cases, you can make 3 displays in one view and define a step of 3 in the paginator.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question