Created
February 25, 2014 15:29
-
-
Save hissy/9211112 to your computer and use it in GitHub Desktop.
[concrete5] Display Year as heading in the list of Page List template
This file contains 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
<?php | |
$dh = Loader::helper('date'); | |
$year = new DateTime('first day of next year'); | |
$isFirst = true; | |
?> | |
<?php foreach ($pages as $page): | |
// Prepare data for each page being listed... | |
$title = $th->entities($page->getCollectionName()); | |
if ($date < $year) { | |
$year = new DateTime('first day of January ' . $date->format('Y')); | |
if ($isFirst) { | |
$isFirst = false; | |
} else { | |
echo '</ul>'; | |
} | |
echo '<h3>' . $dh->date('Y',$year->getTimestamp()) . '</h3>'; | |
echo '<ul class="ccm-page-list">'; | |
} else { | |
$dlClosed = false; | |
} | |
/* The HTML from here through "endforeach" is repeated for every item in the list... */ ?> | |
<li><?php echo $title ?></li> | |
<?php endforeach; ?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment