Zitat von
mlweb
Und warum willst Du es nicht mit Klassen umsetzen?
darum ja auch meine Frage Oder hat jemand einen Ansatz für eine Umsetzung?
... aber zur Erklärung deiner Frage:
die Standard-events bieten keine ausreichenden Klassen, die angesprochen und "pro Termin und Tag" genutzt werden können » sofern ich falsch liege, lerne ich gerne dazu
Bevor ich nun selbst etwas erstellen wollte, dachte ich, dass ich mal in die Runde frage, ob jemand hierzu etwas kennt, jemand etwas nutzt, jemand etwas umgesetzt hat.
Ich hatte mich dann gestern über einen möglichen gedanklichen Lösungsansatz gewagt und bin bis jetzt mal soweit, dass die DCA-Anpassung klappt und auch dargestellt wird. Wobei ich mit Testen und Ausbessern von Feinheiten noch nicht fertig bin.
... wäre aber trotzdem über Abbildungs- und Herangehensweise-Input dankbar, denn aktuell braucht mein Lösungsansatz einen gewissen logischen Aufbau für die Befüllung.
• alles ist mal auf rot gesetzt
• bedingt durch Start- und Enddatum können natürlich ganze Wochen, Monate auf 'offen/grün' gesetzt werden
• zwischendurch können aber weitere Einzeltage oder mehrere von-bis-Daten in gelb oder rot "überschrieben" werden - dies kann sich unter der Saison natürlich ändern.
• dadurch dass zwei Termine an einem Tag untereinander angezeigt werden, muss abgefragt werden, ob schon ein Termin vorhanden ist und dieser dann ausgeblendet werden, damit wiederum nur ein Termin, nämlich einer mit einer 'höheren Priorisierung' angezeigt wird.
Ist hald dumm, dass nach dieser Logik ein Offen/Geschlossen Kalender befüllt werden muss
... darum bin ich um einfachere Ansätze dankbar
PHP-Code:
<?php
// contao/dca/tl_calendar_events.php
use Contao\CoreBundle\DataContainer\PaletteManipulator;
$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['busy'] = [
'label' => ['Belegung','Wählen Sie die Belegung'],
'inputType' => 'select',
'options' => ['','red','green','yellow'],
'reference' => ['' => '-', 'red' => 'rot','green' => 'grün', 'yellow' => 'gelb'],
'default' => '',
'eval' => ['tl_class' => 'clr w50', 'maxlength' => 255],
'sql' => ['type' => 'string', 'length' => 32, 'default' => ''],
];
$GLOBALS['TL_DCA']['tl_calendar_events']['fields']['busyPrio'] = [
'label' => ['Priorität','Dieser event-Eintrag wird mit Priorität behandelt'],
'inputType' => 'checkbox',
'eval' => ['tl_class' => 'w50 m12'],
'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => ''],
];
PaletteManipulator::create()
->addLegend('busy_legend', 'date_legend' , PaletteManipulator::POSITION_BEFORE)
->addField('busy', 'busy_legend', PaletteManipulator::POSITION_APPEND)
->addField('busyPrio', 'busy_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('default','tl_calendar_events');
PHP-Code:
<?php
$GLOBALS['TL_HEAD'][] = '<style>.minicalendar tr td {
color:#fff;
background-color:red;
}
.minicalendar tr td a {
display:block;
color:#fff;
}
.minicalendar .red {
background-color:red;
}
.minicalendar .green {
background-color:green;
}
.minicalendar .yellow {
background-color:yellow;
color:#000;
}
.minicalendar .two.notprior {
display:none;
}
.mod_calendar td.today{
color:#000;
}</style>';
?>
<table class="minicalendar">
<thead>
<tr>
<th class="head previous"><?php if ($this->prevHref): ?><a href="<?= $this->prevHref ?>" rel="nofollow" title="<?= $this->prevTitle ?>"><?= $this->prevLabel ?></a><?php else: ?> <?php endif; ?></th>
<th colspan="5" class="head current"><?= $this->current ?></th>
<th class="head next"><?php if ($this->nextHref): ?><a href="<?= $this->nextHref ?>" rel="nofollow" title="<?= $this->nextTitle ?>"><?= $this->nextLabel ?></a><?php else: ?> <?php endif; ?></th>
</tr>
<tr>
<?php foreach ($this->days as $day): ?>
<th class="label<?= $day['class'] ?>"><?= Patchwork\Utf8::substr($day['name'], 0, $this->substr) ?><span class="invisible"><?= Patchwork\Utf8::substr($day['name'], $this->substr) ?></span></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($this->weeks as $class => $week): ?>
<tr class="<?= $class ?>">
<?php foreach ($week as $day): ?>
<?php $titleClass = (substr($day['title'], 0, 1)); ?>
<?php if ($day['href']): ?>
<td class="<?= $day['class'] ?>">
<?php foreach ($day['events'] as $event): ?>
<a class="<?php if($titleClass == 1) : echo 'one '; else: echo 'two '; endif; ?><?= $event['busy'] ?><?php if (($event['busyPrio']) != 1): ?><?= ' notprior' ?><?php endif; ?>" href="#" title="<?= $day['title'] ?>"><?= $day['label'] ?></a>
<?php endforeach; ?>
</td>
<?php else: ?>
<td class="<?= $day['class'] ?>"><?= $day['label'] ?></td>
<?php endif; ?>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
Lesezeichen