Jump to content

Recommended Posts

Posted

I need to list subpages by mengtest and title of a mother page as a simple foreach ul list. Is there a way, similar to a menu, to list child pages? I couldn't find anything about this in the docs. Maybe you can give me a hint what to look for?

Posted

I was looking at this thread earlier and was confused, but now I’ve had a drink, I think you want to show a single list of pages whose parent matches some conditions?

You can use selectors on fields of the parent like this:

pages()->find('parent.title=something, parent.mengtest=orother')

 

Posted
14 hours ago, BitPoet said:

?

sorry, a typing error:
mengtest = menutext ('menutext|title')

  • Like 1
Posted

@netcarver thanks netcarver, this helped a lot.

echo "<ul id='side-menu' class='uk-list uk-margin-remove uk-padding-remove'>";
foreach($pages->get(1044)->children as $child) {
    $active = wire('page') == $child ? "current" : "";
    echo "<li class='$active'><a href='$child->url' title='$child->title'>" . $child->get('menutext|title') . "</a></li>";
}
echo "</ul>";

I call the list pages in my base template with the page ID of the parent page:

<?php if ($page->id == 1044): ?>
<?php include('views/partials/menu-aside.php'); ?>
<?php endif; ?>

However, the list should also be displayed in all children's pages. ID is therefore wrong? Is there another option which includes the children's sites?

Posted

I might be misunderstanding, but couldn't you do this in the base template...?

<?php if ($page->id == 1044 || $page->parent->id == 1044): ?>

 

  • Like 1
Posted
1 hour ago, netcarver said:

I might be misunderstanding, but couldn't you do this in the base template...?

Exactly, that was my goal, to do it in the base template. Thanks that works!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...