Skip to content

Instantly share code, notes, and snippets.

Created November 29, 2012 11:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4168367 to your computer and use it in GitHub Desktop.
Save anonymous/4168367 to your computer and use it in GitHub Desktop.
Loop for the Archive page
<ul id="archive">
<?php $blog = $pages->find('blog')->children()->visible()->sortBy($sort='date', $dir='desc') ?>
<?php $year = date("Y"); ?>
<?php foreach ($blog as $article): ?>
<?php if ($article->date('Y') <= $year) { ?> <!-- If if the date changes print it -->
<?php $year = $article->date('Y') ?>
<span class="year"><?php echo $year ?></span>
<?php $year-- ?>
<?php } ?>
<li>
<span class="month"><?php echo $article->date('M d') ?></span>
<a href="<?php echo $article->url() ?>" class="articleTitle"><?php echo html($article->title()) ?></a>
</li>
<?php endforeach ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment