Skip to content

Instantly share code, notes, and snippets.

@hissy
Created February 25, 2014 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/9211112 to your computer and use it in GitHub Desktop.
Save hissy/9211112 to your computer and use it in GitHub Desktop.
[concrete5] Display Year as heading in the list of Page List template
<?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