I am finishing up my first processwire site (yay), and this last bit is giving me a bit of a headache: For a news slider, I want to output x number of posts, with three posts per slide. (for a theoretically unlimited number of slides)
I figure in theory this should work something like the code below, however the looping logic, among other things is still somewhat beyond me:
<?php
$items_per_page = 3;
$start = ($pages->get("/news/")->find("sort=sort")->pageNum - 1) * $items_per_page;
$total = count($pages->get("/news/")->find("sort=sort"));
$slicedarticles = $pages->get("/news/")->find("sort=sort")->slice($start, $items_per_page);
foreach ($slicedarticles as $slicedarticle => $total) {
echo "<div class='slide'>";
foreach ($slicedarticle as $article) {
echo "<h3>{$article->title}</h3><p>{$article->body}</p>";
}
echo "</div>";
}
?>
Can someone point me in the right direction with this?
Much appreciated!
Cheers,
Phil