Add configurable sorting order for items
This commit is contained in:
parent
76697e4656
commit
77f97a3a5d
1 changed files with 8 additions and 2 deletions
|
|
@ -152,8 +152,14 @@ switch ($parsedPath['type']) {
|
|||
];
|
||||
}, $subdirs));
|
||||
|
||||
// Sort by date (newest first) if dates are present
|
||||
// Sort by date - check metadata for order preference
|
||||
$sortOrder = strtolower($metadata['order'] ?? 'descending');
|
||||
if ($sortOrder === 'ascending') {
|
||||
usort($items, fn($a, $b) => strcmp($a['date'] ?? '', $b['date'] ?? ''));
|
||||
} else {
|
||||
// Default: descending (newest first)
|
||||
usort($items, fn($a, $b) => strcmp($b['date'] ?? '', $a['date'] ?? ''));
|
||||
}
|
||||
|
||||
// Prepare all variables for base template
|
||||
$navigation = $ctx->navigation;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue