Update pico.php

This is only a suggestion and could be expanded and changed but for my project and what I'm working on this seemed good enough.

Essentially this allows the possibility for the Date: meta field within the markdown content files to be written in various ways which will all be converted to ISO YYYY-MM-DD-ID before being sorted. This should also in theory speed up the process on much larger sites.

Additionally, I've changed how files without a date are sorted within the array: by the date the page was last modified. 

So essentially the logic goes:

if meta.date then meta.date else page.modified > sort

This could be expanded to allow the date modified to be read by the date_formatted or what have you, however it could break some people's sites whereby they utilise various data attribute within twig. Though one would assume they would be doing this on the date meta identifier. 

Anyhow, food for thought.

- Andrew
:)
This commit is contained in:
Andrew Tajsic 2013-07-24 11:05:06 +10:00
parent ec37ff4e75
commit 7dcc2b6ed9

View file

@ -236,7 +236,8 @@ class Pico {
'excerpt' => $this->limit_words(strip_tags($page_content), $excerpt_length)
);
if($order_by == 'date'){
$sorted_pages[$page_meta['date'].$date_id] = $data;
$date_sort = (empty($page_meta['date'])) ? date("o-m-d", filemtime($page)) : date("o-m-d", strtotime($page_meta['date']));
$sorted_pages[$date_sort . "-" . $date_id] = $data;
$date_id++;
}
else $sorted_pages[] = $data;
@ -336,4 +337,4 @@ class Pico {
}
?>
?>