function template_preprocess_calendar_month in Calendar 8
Same name and namespace in other branches
- 6.2 theme/theme.inc \template_preprocess_calendar_month()
- 6.2 calendar_multiday/theme/theme.inc \template_preprocess_calendar_month()
- 7.3 theme/theme.inc \template_preprocess_calendar_month()
- 7 theme/theme.inc \template_preprocess_calendar_month()
- 7 calendar_multiday/theme/theme.inc \template_preprocess_calendar_month()
- 7.2 theme/theme.inc \template_preprocess_calendar_month()
- 7.2 calendar_multiday/theme/theme.inc \template_preprocess_calendar_month()
Display a month view.
1 call to template_preprocess_calendar_month()
- template_preprocess_calendar_mini in ./
calendar.theme.inc - Display a mini month view.
File
- ./
calendar.theme.inc, line 18 - Theme functions for the Calendar module.
Code
function template_preprocess_calendar_month(&$vars) {
$view = $vars['view'];
$rows = $vars['rows'];
if (empty($rows)) {
$rows = [];
$day_names = [];
}
elseif (count($rows) > 1) {
$day_names = array_shift($rows);
}
else {
$day_names = $rows;
$rows = [];
}
$month_rows = $rows;
foreach ($rows as $weekno => $row) {
// If this row is already rendered, don't do anything.
if (!isset($row['data'])) {
foreach ($row as $day => $data) {
$cell = $data['data'];
// If this cell is already rendered, like the weekno column,
// move to the next item.
if (!is_array($cell)) {
$month_rows[$weekno][$day]['data'] = $cell;
continue;
}
$data = [
$cell['datebox'],
];
if ($cell['empty']) {
$data[] = $cell['empty'];
}
else {
$data[] = $cell['all_day'];
foreach ($cell['items'] as $hour => $item) {
$data[] = $item;
}
$data[] = $cell['link'];
}
$month_rows[$weekno][$day]['data'] = \Drupal::service('renderer')
->render($data);
}
}
}
$vars['rows'] = $month_rows;
$vars['day_names'] = $day_names;
$vars['display_type'] = $view->dateInfo
->getGranularity();
$vars['min_date_formatted'] = $view->dateInfo
->getMinDate()
->format(DateTimeItemInterface::DATE_STORAGE_FORMAT);
$vars['max_date_formatted'] = $view->dateInfo
->getMaxDate()
->format(DateTimeItemInterface::DATE_STORAGE_FORMAT);
$vars['date'] = $view->dateInfo
->getMinDate()
->format('Y-m');
}