Sorty by date and time .. pagination?

I’m sorting my articles with date AND time. Because I’m sure to write more than one article at one day.

date and time

pages: sort: date asc time asc

$limit = c::get('pagination-blog', 5); $articles = page('blog')->children()->visible()->flip()->paginate($limit); $pagination = $articles->pagination();


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

Without pagination he sorts it right. With this pagination he’s not sorting all articles.

The sorting should be defined in the controller/beginning of template, not in the foreach loop.

$limit = c::get('pagination-blog', 5);
$articles = page('blog')->children()->visible()->flip()->paginate($limit)->sortBy('date', 'desc', 'time', 'desc');
$pagination = $articles->pagination();

This code in blog.php?
If I do this I become an error This page is currently offline due to an unexpected error

@listing.php it’s not inside the loop

Sorry, I made a mistake:

$limit = c::get('pagination-blog', 5);
$articles = page('blog')->children()->visible()->sortBy('date', 'desc', 'time', 'desc')->flip()->paginate($limit);
$pagination = $articles->pagination();
foreach($articles as $article) {
  // your code

Please turn on debugging in your config.php

c::set('debug', true);

to be able to see the errors.

Yay this works. Thank you (again). But whats about

pages: template: article num: date sort: date asc time asc

@blog.yml ? Why I need ->sortBy('date', 'desc', 'time', 'desc') to sort it?

Because the sort settings in the blueprint only apply to the sort order of the subpages in the Panel, it has no effect whatsoever on the frontend.

aaah … ok :slight_smile: understood