Ich habe dazu in meiner Erweiterung [newslinklist] folgende Lösung in newslinklist/dca/tl_content:
PHP-Code:
// Nachrichtenliste anzeigen
$GLOBALS['TL_DCA']['tl_content']['fields']['newslinklist'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_content']['newslinklist'],
'exclude' => true,
'options_callback' => array('tl_content_newslinklist', 'getNewslinklist'),
'inputType' => 'checkboxWizard',
'eval' => array('mandatory'=>false, 'multiple'=>true, 'class'=>'clr'),
'sql' => "blob NULL",
);
class tl_content_newslinklist extends Backend
{
public function getNewslinklist(DataContainer $dc)
{
// Erlaubte Archivliste laden
($GLOBALS['TL_CONFIG']['newslinklist_archive']) ? $newsarchive = unserialize($GLOBALS['TL_CONFIG']['newslinklist_archive']) : $newsarchive = array();
// Nachrichtenarchive laden und zuordnen
$objNewsArchive = $this->Database->prepare("SELECT id, title FROM tl_news_archive")
->execute();
while($objNewsArchive->next())
{
if(in_array($objNewsArchive->id, $newsarchive))
{
$NewsArchiv[$objNewsArchive->id] = $objNewsArchive->title;
}
}
$von = $GLOBALS['NEWSLINKLIST']['start'];
$bis = $GLOBALS['NEWSLINKLIST']['stop'];
$array = array();
if($von && $bis) $objNews = $this->Database->prepare("SELECT id, pid, headline, date, published, start, stop FROM tl_news WHERE date > ? AND date < ? ORDER BY date DESC")->execute($von, $bis);
else $objNews = $this->Database->prepare("SELECT id, pid, headline, date, published, start, stop FROM tl_news ORDER BY date DESC")->execute();
while($objNews->next())
{
// Veröffentlichungsstatus ermitteln
if((!$objNews->start || $objNews->start < time()) && (!$objNews->stop || $objNews->stop > time()) && $objNews->published) $published = true;
else $published = false;
if($NewsArchiv[$objNews->pid])
{
if($published) $array[$objNews->id] = date($GLOBALS['TL_CONFIG']['datimFormat'], $objNews->date).' <b>'.$objNews->headline.'</b> ['.$NewsArchiv[$objNews->pid].']';
else $array[$objNews->id] = date($GLOBALS['TL_CONFIG']['datimFormat'], $objNews->date).' <i>'.$objNews->headline.'</i> ('.$GLOBALS['TL_LANG']['tl_content']['nll_unpublished'].') ['.$NewsArchiv[$objNews->pid].']';
}
}
return $array;
}
}
In mein Feld vom Typ checkboxWizard lese ich alle Nachrichtentitel mit der Nachrichten-ID als Index von den erlaubten Nachrichtenarchiven ein. Da ich über 12.000 Nachrichten im System habe, habe ich noch eine Einschränkung via Zeitraum geschaffen.