From fc9409e5a1e04cd4d96264cde4aed7f1be49da01 Mon Sep 17 00:00:00 2001 From: KIKIJIKI Date: Sun, 12 May 2013 19:52:27 +0900 Subject: [PATCH] Fixed the problem with pages having the same date. If the order is by date and some pages have the same date, only one will be added to the array because it uses the date as the key. By adding an auto-incrementing id the key is guaranteed to be unique. --- lib/pico.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pico.php b/lib/pico.php index 8a45ef9..d2230bd 100644 --- a/lib/pico.php +++ b/lib/pico.php @@ -211,6 +211,7 @@ class Pico { $pages = $this->get_files(CONTENT_DIR, CONTENT_EXT); $sorted_pages = array(); + $date_id = 0; foreach($pages as $key=>$page){ // Skip 404 if(basename($page) == '404'. CONTENT_EXT){ @@ -234,7 +235,10 @@ class Pico { 'content' => $page_content, 'excerpt' => $this->limit_words(strip_tags($page_content), $excerpt_length) ); - if($order_by == 'date') $sorted_pages[$page_meta['date']] = $data; + if($order_by == 'date'){ + $sorted_pages[$page_meta['date'].$date_id] = $data; + $date_id++; + } else $sorted_pages[] = $data; }