Die Kalender- bzw. Mini-Kalender-Anzeige hat am Ende eines Monats den Nachteil, dass man nicht weit in die Zukunft blicken kann.
Die Lösung: den aktuellen und den folgenden Monat anzeigen. Dann hat man mindestens 4 Wochen im Überblick.
Leider ist es mir nicht gelungen, das durch Anpassung von mini_cal.tpl zu realisieren.
Aber mit einer Modifikation von
system/modules/calendar/ModuleCalendar.php
klappt es ganz gut.
Hier der veränderte Ausschnitt (ab Zeile 109)
PHP-Code:
/**
* Generate module
*/
protected function compile()
{
// Respond to month
if ($this->Input->get('month'))
{
$this->Date = new Date($this->Input->get('month'), 'Ym');
}
// Respond to day
elseif ($this->Input->get('day'))
{
$this->Date = new Date($this->Input->get('day'), 'Ymd');
}
// Fallback to today
else
{
$this->Date = new Date();
}
$intYear = date('Y', $this->Date->tstamp);
$intMonth = date('m', $this->Date->tstamp);
$objTemplate = new FrontendTemplate(($this->cal_ctemplate ? $this->cal_ctemplate : 'cal_default'));
$objTemplate->intYear = $intYear;
$objTemplate->intMonth = $intMonth;
// Previous month
$prevMonth = ($intMonth == 1) ? 12 : ($intMonth - 1);
$prevYear = ($intMonth == 1) ? ($intYear - 1) : $intYear;
$lblPrevious = $GLOBALS['TL_LANG']['MONTHS'][($prevMonth - 1)] . ' ' . $prevYear;
$objTemplate->prevHref = $this->strUrl . ($GLOBALS['TL_CONFIG']['disableAlias'] ? '?id=' . $this->Input->get('id') . '&' : '?') . 'month=' . $prevYear . str_pad($prevMonth, 2, 0, STR_PAD_LEFT);
$objTemplate->prevTitle = specialchars($lblPrevious);
$objTemplate->prevLink = $GLOBALS['TL_LANG']['MSC']['cal_previous'] . ' ' . $lblPrevious;
$objTemplate->prevLabel = $GLOBALS['TL_LANG']['MSC']['cal_previous'];
// Current month
$objTemplate->current = $GLOBALS['TL_LANG']['MONTHS'][(date('m', $this->Date->tstamp) - 1)] . ' ' . date('Y', $this->Date->tstamp);
// Next month
$nextMonth = ($intMonth == 12) ? 1 : ($intMonth + 1);
$nextYear = ($intMonth == 12) ? ($intYear + 1) : $intYear;
$lblNext = $GLOBALS['TL_LANG']['MONTHS'][($nextMonth - 1)] . ' ' . $nextYear;
$objTemplate->nextHref = $this->strUrl . ($GLOBALS['TL_CONFIG']['disableAlias'] ? '?id=' . $this->Input->get('id') . '&' : '?') . 'month=' . $nextYear . str_pad($nextMonth, 2, 0, STR_PAD_LEFT);
$objTemplate->nextTitle = specialchars($lblNext);
$objTemplate->nextLink = $lblNext . ' ' . $GLOBALS['TL_LANG']['MSC']['cal_next'];
$objTemplate->nextLabel = $GLOBALS['TL_LANG']['MSC']['cal_next'];
// Set week start day
if (!$this->cal_startDay)
{
$this->cal_startDay = 0;
}
$objTemplate->days = $this->compileDays();
$objTemplate->weeks = $this->compileWeeks();
// --------------------------------------------------------- start of modification
// and now the same for next month...
$this->Date = new Date($nextYear . str_pad($nextMonth, 2, 0, STR_PAD_LEFT), 'Ym');
$objTemplate2 = new FrontendTemplate(($this->cal_ctemplate ? $this->cal_ctemplate : 'cal_default'));
$objTemplate2->intYear = $nextYear;
$objTemplate2->intMonth = $nextMonth;
// Previous month 2
$prevMonth2 = $intMonth;
$prevYear2 = $intYear;
$lblPrevious2 = $GLOBALS['TL_LANG']['MONTHS'][($prevMonth2 - 1)] . ' ' . $prevYear2;
$objTemplate2->prevHref = $this->strUrl . ($GLOBALS['TL_CONFIG']['disableAlias'] ? '?id=' . $this->Input->get('id') . '&' : '?') . 'month=' . $prevYear . str_pad($prevMonth, 2, 0, STR_PAD_LEFT);
$objTemplate2->prevTitle = specialchars($lblPrevious2);
$objTemplate2->prevLink = $GLOBALS['TL_LANG']['MSC']['cal_previous'] . ' ' . $lblPrevious2;
$objTemplate2->prevLabel = $GLOBALS['TL_LANG']['MSC']['cal_previous'];
// Current month 2
$objTemplate2->current = $GLOBALS['TL_LANG']['MONTHS'][$nextMonth - 1] . ' ' . $nextYear;
// Next month
$nextMonth2 = ($nextMonth2 == 12) ? 1 : ($nextMonth2 + 1);
$nextYear2 = ($nextMonth2 == 12) ? ($nextYear2 + 1) : $nextYear2;
$lblNext2 = $GLOBALS['TL_LANG']['MONTHS'][($nextMonth2 - 1)] . ' ' . $nextYear2;
$objTemplate2->nextHref = $this->strUrl . ($GLOBALS['TL_CONFIG']['disableAlias'] ? '?id=' . $this->Input->get('id') . '&' : '?') . 'month=' . $nextYear . str_pad($nextMonth, 2, 0, STR_PAD_LEFT);
$objTemplate2->nextTitle = specialchars($lblNext2);
$objTemplate2->nextLink = $lblNext2 . ' ' . $GLOBALS['TL_LANG']['MSC']['cal_next'];
$objTemplate2->nextLabel = $GLOBALS['TL_LANG']['MSC']['cal_next'];
$objTemplate2->days = $this->compileDays();
$objTemplate2->weeks = $this->compileWeeks();
$this->Template->calendar2 = $objTemplate2->parse();
// ----------------------------------------------------------- end of modification
$this->Template->calendar = $objTemplate->parse();
}
Hier wird zunächst nur eine eigene Variable für den Folgemonat vorbereitet. Durch eine Anpassung von mod_calendar.tpl kann der zweite Monat angezeigt werden:
PHP-Code:
<!-- indexer::stop -->
<div class="<?php echo $this->class; ?> block"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
<div class="br">
<?php if ($this->headline): ?>
<<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
<?php endif; ?>
<?php echo $this->calendar; ?>
<div class="divider"></div>
<?php echo $this->calendar2; ?>
</div>
</div>
<!-- indexer::continue -->
Diese Änderung geht bei Updates wieder verloren - ModuleCalendar.php muss also nach jedem Update restauriert werden. Falls diese Idee Anklang findet, dann wäre eine Übernahme in die offizielle Release natürlich sehr schön.
Über Kritik und Anregungen würde ich mich freuen,
folkfreund
Lesezeichen