Panel: page order and date

Good morning everybody!

This is just a general thought, and more a practical question than an issue:
Did i miss something or is it correct that on the panel the pages (and subpages, for instance project or blog pages) are listed in a way that the oldest one is on top and the newest one at the bottom of the list? Wouldn’t it be fine to be able to flip the order so one has access to the latest updates immediately? This might be especially useful when one has very many pages in the directory.

Another question: It would be fine to see the date of each page on the panel. For instance sometimes I need to add a page in between (pageX) that gets a time stamp of ages ago but still it appears at the end of the panel list. I use to drag pageX to the correct place in the list, but for that I have to check the surrounding page files for their dates.

To gain a correct order in my blog I wrote this in my blog template:

<?php foreach($articles->sortBy('date', 'desc') as $article): ?>

But this does not work with pagination; pageX remains always on page 1, unless I drag it into the correct order on the panel. It seems that I forgot something in my template?

[https://getkirby.com/docs/panel/blueprints/subpages-settings#reverse-sorting-of-subpages](Panel - Reverse sorting of subpages)

Also interesting on the linked Page “Date-based numbering”.

Maybe you want to save your ordered Articles into another Variable first.

$sortedArticles = $articles->sortBy('date', 'desc');

To see if you missed something in your Template I would need to see more Code…

1 Like

Perfect, thank you. So simple!

This is my code:

The template:

<h2><?php echo $page->title()->html() ?></h2>
<?php echo $page->text()->kirbytext() ?>
				
<!-- articles -->
<?php foreach($articles->sortBy('date', 'desc') as $article): ?>`
<article>
    <a href="<?php echo $article->url() ?>"><?php echo $article->title()->html() ?></a>
</article>
<?php endforeach ?>

<nav class="nextprev cf" role="navigation">
  <?php if($pagination->hasPrevPage()): ?>
  <div class="prev"><a href="<?php echo $pagination->prevPageUrl() ?>"> &larr;Neuere Beiträge</a></div>
  <?php endif ?>
				
  <?php if($pagination->hasNextPage()): ?>
  <div class="next"><a href="<?php echo $pagination->nextPageUrl() ?>">Ältere Beiträge &rarr;</a></div>
  <?php endif ?>
</nav>

That’s all.

The controller:

<?php return function($site, $pages, $page) {
  $articles = $page->children()->visible()->flip();
  $articles   = $articles->paginate(10);
  $pagination = $articles->pagination();
  return compact('articles', 'pagination');
}; ?>