Created
November 5, 2015 16:39
-
-
Save floriandotpy/706a365282f49cb1ad44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title : Home | |
layout: blog/index | |
=== | |
<!-- Find blog folders 2010, 2011, ... --> | |
<?php $years = $page->children()->filter(function($p) { return preg_match("/^\d{4}$/", $p->slug()); }); ?> | |
<!-- Go through all blog folders, collect articles in one single array --> | |
<?php $allarticles = []; ?> | |
<?php foreach ($years as $year): ?> | |
<?php foreach ($year->children() as $article): ?> | |
<?php $allarticles[] = $article; ?> | |
<?php endforeach; ?> | |
<?php endforeach; ?> | |
<!-- Turn back into PageCollection and sort by date --> | |
{% $page->set('articles', (new COCOPi\Lib\PageCollection($allarticles))->visible()->sort('$p->meta("date")', 'desc')) %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment