tooth-paste Posted September 11, 2018 Share Posted September 11, 2018 Help, I'am lost here! Goal: show all movies from different children. Tree: -Movies --Comedy (this page contains field with movies ) --SciFi (this page contains field with movies ) --Thiller (this page contains field with movies ) $items = $pages->get("/portal/movies/")->children; foreach ($items as $item) { $name = str_replace("_", " ", $item->name); echo '<div class="row" style="padding:7px 0 5px 0"> <div class="col-md-6"> <a href="'. $item->url .'">'. $name .'</a><br /> </div> <div class="col-md-2"> '. $item->filesizeStr .'<br /> </div> <div class="col-md-4"> '. $item->description .'<br /> </div> </div> <div class="row"> <div class="col-md-12 lijn"> <div class="lijn"></div> </div> </div>'; } Link to comment Share on other sites More sharing options...
rafaoski Posted September 11, 2018 Share Posted September 11, 2018 (edited) Maybe try using two foreach loops: <?php foreach ($pages->get('/portal/movies/')->children as $movieCategory) { echo "<h3><a href='$movieCategory->url'>$movieCategory->title</a></h3>"; echo '<ul>'; // Get movie Children foreach ($movieCategory->children as $movie ) { echo "<li><a href='$movie->url'> $movie->title </a></li>"; } echo '<ul>'; } ?> Or using $pages->find() ... Show children from the template, which is assigned to a single movie: <ul><?php // https://processwire.com/api/ref/pages/find/ $items = $pages->find("template=single-movie, limit=12"); // Loop foreach ($items as $item) { echo "<li><a href='$item->url'>$item->title</a></li>"; } ?></ul> <?php // Pagination https://processwire.com/api/modules/markup-pager-nav/ $pagination = $items->renderPager(); echo $pagination;?> Edited September 11, 2018 by rafaoski Update 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now