function agenda_display_block in Agenda 6.2
Same name and namespace in other branches
- 6 agenda.module \agenda_display_block()
- 7.2 agenda.module \agenda_display_block()
- 7 agenda.module \agenda_display_block()
Generate the themed agenda block
Return value
string
1 call to agenda_display_block()
- agenda_block in ./
agenda.module - Implementation of hook_block().
File
- ./
agenda.module, line 184
Code
function agenda_display_block($delta = 0) {
// Check block exists
if ($delta === 0 || !($block = agenda_settings($delta))) {
return false;
}
// Group the events by date
$events = agenda_get_events($block);
$groupedevents = array();
foreach ($events as $event) {
$groupedevents[$event['when']][] = $event;
}
ksort($groupedevents);
// Filter the events based on their date
$datelimit = $block->datelimit;
$count = 0;
$events = array();
foreach ($groupedevents as $date => $eventdata) {
if ($count >= $datelimit) {
break;
}
$events[$date] = $eventdata;
$count++;
}
// Render
if (count($events)) {
$output = theme('agenda_block', $events, $block);
}
elseif (empty($block->noeventstext)) {
$output = NULL;
}
else {
$output = filter_xss($block->noeventstext);
}
return $output;
}