Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Community Answers

  1. elabx's post in Navigation Disaster was marked as the answer   
    This is cleared by the answer written by Tom.
    I will elaborate on his answer just trying to include the HTML you wrote a few posts back, I hope it makes it more clear. I'm not exactly sure the syntax of the nested dropwdowns is correct, hope you get the idea.
    <?php $results = $pages->get("/")->children("template=events|articles");  //$result is one of your "content types", in this example, it could be Articles or Events page object. ?> <?php foreach ($results as $result): ?>    <li class="dropdown">          <a href=""    class="dropdown-toggle"    data-toggle="dropdown"    role="button" aria-haspopup="true"    aria-expanded="false"><?php echo $result->title //This would echo either "Article" or "Events" ?>       <span class="caret"></span>     </a>          <ul class="dropdown-menu">       <?php foreach($result->children as $user):?>         <li><a href='<?php echo $user->url ?>'><?php echo $user->title ?></a>   <?php foreach($user->children as $item): //This would be an article or event in itself?>      <li><a href='<?php echo $user->url ?>'><?php echo $user->title ?></a>   <?php endforeach; ?>   </li> <?php endforeach;?>     </ul> </li> <?php endforeach; ?> This could be included anywhere in any template and render the same, because $pages (whatch out for that plural!) variable that let's retrieve any page no matter where you are on the tree. The $pages->get() retrieves one page, in this case the root page, and the next method "children", returns the PageArray whose contained pages matches the selector.
    The only thing I don't like about this is that I would need to specify the selector's parameters in case I add more "content types". But that's more of a topic on how you would plan your website. 
  • Create New...