stuart-b
4/20/2018 - 3:23 PM

Tile rows

If statement to add to correctly wrap rows of three tiles

<?php
                $count = 1;
                foreach ($latest_items as $item_id) {

                    if (($count == 1) || ($count % 3 === 1 && $count !== 2)) {
                        ?>
                        <div class="js-tile-row">
                        <?php
                    }

                    $view = new View(new Path(), 'assets/views/tile.php');
                    $view->setVars([
                        'item_id'     => $item_id,
                    ]);
                    echo $view->output();

                    if ($count % 3 === 0 && $count !== 0) {
                        ?>
                        </div>
                        <div class="u-clear"></div>
                        <?php
                    }

                    $count++;
                }
                ?>