Jump to content

Siblings Knowagle


drilonb
 Share

Recommended Posts

It's possible to make Siblings with limit, sort, i make like this works perfect but show older in top

<?php
           echo "<ul class='menuposht'>";
           foreach($page->siblings as $sibling) {
           $class = $page === $sibling ? " class='active'" : '';
           echo "<li><a$class href='{$sibling->url}'>{$sibling->title}</a></li>";
           }
           echo "</ul>";

for now i am using like this to sort them and limit, works nice, but i like to use sibling

<?php
           $children = $pages->get("/puna/")->children("sort=-created, limit=3");
           foreach($children as $puna) {    
           $class = $page === $puna ? " class='active'" : '';
           echo "
           <ul class='menuposht'>
           <li><a$class href='{$puna->url}'>{$puna->title}</a></li>
           </ul>
           ";
           }

Thanks.

Link to comment
Share on other sites

This is possible. The siblings method will accept a selector just like others will:

<?php
echo "<ul class='menuposht'>";
foreach($page->siblings("sort=-created, limit=3") as $sibling) {
    $class = $page === $sibling ? " class='active'" : '';
    echo "<li><a$class href='{$sibling->url}'>{$sibling->title}</a></li>";
}
echo "</ul>";
Link to comment
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
 Share

  • Recently Browsing   0 members

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