Jump to content
Sign in to follow this  
tooth-paste

Show all movies from children

Recommended Posts

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>';
												
										}

 

Share this post


Link to post
Share on other sites

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 by rafaoski
Update
  • Like 1

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...