Hallo zusammen,
auch wenn das Thema schon uralt ist, möchte ich die Lösung hier unterbreiten, da ich sie soeben selbst implementieren musste. Das ganze funktioniert nur durch eine Modulerweiterung. Diese ist aber ganz einfach umzusetzen:
Ich habe die Erweiterung im Verzeichnis xTend implementiert danach Verzeichnisstruktur der Modulerweiterung wie gehabt:
Code:
[config]
--> config.php
--> database.sql
[dca]
--> tl_module.php
ModuleEventlistExt.php
danach folgenden Code in die Dateien.
/system/modules/xTend/config/config.php
Laden der Erweiterung:
Code:
<?php if (!defined('TL_ROOT')) { die('You can not access this file directly!');}
$GLOBALS['FE_MOD']['events']['eventlist'] = 'ModuleEventlistExt';
/system/modules/xTend/config/database.sql
Datenbank anpassen
Code:
CREATE TABLE `tl_module` (
`cal_mod_template` varchar(32) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/system/modules/xTend/dca/tl_module.php
Neues Feld zum auswählen des Templates definieren
Code:
<?php if (!defined('TL_ROOT')) { die('You can not access this file directly!');}
$GLOBALS['TL_DCA']['tl_module']['palettes']['eventlist'] = str_replace(',cal_template', ',cal_template, cal_mod_template',$GLOBALS['TL_DCA']['tl_module']['palettes']['eventlist']);
$GLOBALS['TL_DCA']['tl_module']['fields']['cal_mod_template'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_module']['ca_mod_template'],
'default' => 'event_full',
'exclude' => true,
'inputType' => 'select',
'options_callback' => array('tl_module_calender_ext', 'getModuleTemplates'),
'eval' => array('tl_class'=>'w50')
);
class tl_module_calender_ext extends tl_module_calendar {
public function getModuleTemplates(DataContainer $dc)
{
// fix issue #70 - template selector shall only show relevant templates.
if (version_compare(VERSION.'.'.BUILD, '2.9.0', '>='))
{
return $this->getTemplateGroup('mod_' . $dc->activeRecord->type, $dc->activeRecord->pid);
}
else
{
// backwards compatibility only
if (version_compare(VERSION.'.'.BUILD, '2.8.0', '>='))
$type = $dc->activeRecord->type;
else
{
// 2.7 and below do not have activeRecord.
$objModule=$this->Database->prepare("SELECT type FROM tl_module m WHERE m.id=?")
->execute($dc->id);
$type = $objModule->type;
}
return $this->getTemplateGroup('mod_' . $type);
}
}
}
/system/modules/xTend/ModuleEventlistExt.php
Template in der Klasse zuweisen
Code:
<?php if (!defined('TL_ROOT')) { die('You can not access this file directly!');}
class ModuleEventlistExt extends ModuleEventlist {
public function __construct(Database_Result $objModule, $strColumn='main') {
parent::__construct($objModule, $strColumn) ;
$this->strTemplate = ($this->cal_mod_template) ? $this->cal_mod_template : $this->strTemplate;
}
}
Datenbank aktualisieren nicht vergessen. Voila wir können ein mod_eventlist Template auswählen
Lesezeichen