Skip to content

Instantly share code, notes, and snippets.

@Mark-H
Created March 19, 2011 01:08
Show Gist options
  • Save Mark-H/877111 to your computer and use it in GitHub Desktop.
Save Mark-H/877111 to your computer and use it in GitHub Desktop.
<?php
$c = $modx->newQuery('modResource');
$c->where(array(
'published' => 1,
'hidemenu' => 0));
$c->sortby('unpub_date','asc');
$c->limit(10);
$resources = $c->getCollection('modResource',$c);
$months = array();
foreach ($resources as $res) {
$m = date('n',strtotime($res->get('unpub_date')));
$months[$m][] = $res;
}
// Now loop through the months and add to the output.
$o = '';
$month_names = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
foreach ($months as $mon) {
$o .= $month_names[$mon];
foreach ($mon as $event) {
$o .= $modx->getChunk('tplChunkName',$event->toArray());
}
}
return $o;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment