Super. Vielen Dank für die Info. Hab mir das jetzt zusammengeprügelt. Nicht hübsch und geht bestimmt auch viel besser, aber scheint ordentlich zu funktionieren
PHP-Code:
protected function compile()
{
$year=date('Y');
//Prüfung ob Variable ausschliesslich Zahlen enthält
if(ctype_digit($_GET["eid"])): $ammonid = $_GET["eid"]; endif;
// id des Objektes raussuchen
$objectid = $this->Database->prepare("SELECT id FROM tl_la_bookingcal_objects WHERE name=?")
->execute($ammonid);
// Kalender id in $object Variable übergeben :)
$object = $objectid->fetchAllAssoc()[0]['id'];
// Ausgabe nur ausführen, wenn es einen Kalender für dieses Objekt gibt
if($objectid->fetchAllAssoc()[0]['id'] != false):
for($i=0;$i<=$this->la_bookingcal_years;$i++)
{
$objTemplate = new FrontendTemplate($this->la_bookingcal_template);
// Set timestamps to the beginning and end of the year
$yearStart=mktime(0,0,0,1,1,$year);
$yearEnd=mktime(0,0,0,12,31,$year);
$objDates = $this->Database->prepare("SELECT id,startDate,endDate,startFull,endFull FROM tl_la_bookingcal_dates WHERE pid=? AND (endDate >=? AND startDate <= ?) ORDER BY endDate")
->execute($object,$yearStart,$yearEnd);
$objTemplate->year=$year;
$this->arrayYear = $objDates->fetchAllAssoc();
$objTemplate->months=$this->generateMonths($year);
$strBookings .= $objTemplate->parse();
$year++;
}
$this->Template->bookingcal = $strBookings;
// Get object name to include in the CSS classes
$objName = $this->Database->prepare("SELECT name FROM tl_la_bookingcal_objects WHERE id=?")
->execute($object);
$this->Template->objectName = 'la_'.strtolower(str_replace(' ','-',$objName->fetchAllAssoc()[0]['name']));
endif;
}
Muss nur drauf achten, dass ich das beim Updaten nicht vergesse
Lesezeichen