Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #25 from purerstamp/patch-1
Support any valid date format when sorting pages
  • Loading branch information
rewdy committed Mar 20, 2022
2 parents 198f251 + 21abfa8 commit 270a8c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 10-Pagination.php
Expand Up @@ -5,7 +5,7 @@
* @author Andrew Meyer
* @link http://rewdy.com
* @license http://opensource.org/licenses/MIT
* @version 1.6
* @version 1.7
*/
class Pagination extends AbstractPicoPlugin {

Expand Down Expand Up @@ -59,8 +59,8 @@ public function onPagesLoaded(&$pages, &$currentPage, &$previousPage, &$nextPage
// get total pages before show_pages is sliced
$this->total_pages = ceil(count($show_pages) / $this->config['limit']);
// sort $show_pages by $page['date']:
$pdate = array_column($show_pages, 'date');
array_multisort($pdate, SORT_DESC, $show_pages);
$pdate = array_map('strtotime', array_column($show_pages, 'date'));
array_multisort($pdate, SORT_DESC, SORT_NUMERIC, $show_pages);
// slice show_pages to the limit
$show_pages = array_slice($show_pages, $this->offset, $this->config['limit']);
// set filtered pages to paged_pages
Expand Down
1 change: 1 addition & 0 deletions readme.md
Expand Up @@ -4,6 +4,7 @@ Provides basic pagination for [Pico](http://pico.dev7studios.com).

## Changelog

**1.7** - Changed date sorting to allow the use of any PHP valid date format
**1.6** - Fixed a sorting issue when using subfolders.
**1.5** - Added `next_page_url` and `prev_page_url` variables for Twig. Preparing to stop returning markup from the plugin in a future release—plugin should only return data and leave theming up to site builders.
**1.4** - Changed to use of `>/<` in default next_text and prev_text variables and added more variables Google search-like numbered pagination.
Expand Down

0 comments on commit 270a8c8

Please sign in to comment.