Danke Spooky,
genau das war es was ich gesucht habe. Habe es angepasst und es funktioniert. (Beschränkt auf die Content Elemente meines Modules nicht global Alle. Global alle Content Elemente zu ermitteln sollte mit einer kleinen Anpassung aber auch möglich sein.)
Für alle die es Interessiert, kurz was ich gemacht habe.
tl_content in meinem Modul:
PHP-Code:
/**
* Dynamically add parent table and set getAlias-Function to find CE's in this module
*/
if (\Input::get('do') == 'j***-j***') {
$GLOBALS['TL_DCA']['tl_content']['config']['ptable'] = 'tl_j***_j***';
$GLOBALS['TL_DCA']['tl_content']['fields']['cteAlias']['options_callback'] = array('J***J***Backend', 'getAlias');
}
Dann in die Klasse 'J***J***Backend':
PHP-Code:
/**
* Get all content elements and return them as array (content element alias)
*
* @return array
*/
public function getAlias() {
$parentIds = array();
$alias = array();
if (!$this->User->isAdmin) {
foreach ($this->User->pagemounts as $id) {
$parentIds[] = $id;
$parentIds = array_merge($parentIds, $this->Database->getChildRecords($id, 'tl_j***_j***_category'));
}
if (empty($parentIds)) {
return $alias;
}
$contentElements = $this->Database->prepare("SELECT c.id, c.pid, c.type, (CASE c.type WHEN 'module' THEN m.name WHEN 'form' THEN f.title WHEN 'table' THEN c.summary ELSE c.headline END) AS headline, c.text, a.title FROM tl_content c LEFT JOIN tl_j***_j*** a ON a.id=c.pid LEFT JOIN tl_module m ON m.id=c.module LEFT JOIN tl_form f on f.id=c.form WHERE a.pid IN(". implode(',', array_map('intval', array_unique($parentIds))) .") AND (c.ptable='tl_***_***' OR c.ptable='') AND c.id!=? ORDER BY a.title, c.sorting")->execute(\Input::get('id'));
} else {
$contentElements = $this->Database->prepare("SELECT c.id, c.pid, c.type, (CASE c.type WHEN 'module' THEN m.name WHEN 'form' THEN f.title WHEN 'table' THEN c.summary ELSE c.headline END) AS headline, c.text, a.title FROM tl_content c LEFT JOIN tl_j***_j*** a ON a.id=c.pid LEFT JOIN tl_module m ON m.id=c.module LEFT JOIN tl_form f on f.id=c.form WHERE (c.ptable='tl_j***_j***' OR c.ptable='') AND c.id!=? ORDER BY a.title, c.sorting")->execute(\Input::get('id'));
}
while ($contentElements->next()) {
$headlineArray = deserialize($contentElements->headline, true);
if (isset($headlineArray['value'])) {
$headline = \StringUtil::substr($headlineArray['value'], 32);
} else {
$headline = \StringUtil::substr(preg_replace('/[\n\r\t]+/', ' ', $headlineArray[0]), 32);
}
$text = \StringUtil::substr(strip_tags(preg_replace('/[\n\r\t]+/', ' ', $contentElements->text)), 32);
$strText = $GLOBALS['TL_LANG']['CTE'][$contentElements->type][0] . ' (';
if ($headline != '') {
$strText .= $headline . ', ';
} elseif ($text != '') {
$strText .= $text . ', ';
}
$key = $contentElements->title . ' (ID ' . $contentElements->pid . ')';
$alias[$key][$contentElements->id] = $strText . 'ID ' . $contentElements->id . ')';
}
return $alias;
}
Vielleicht hilft es ja jemanden.
PS: Ich muss leider ein paar Namen unkenntlich machen, daher die ***. Bitte beachtet das beim übernehmen. ^^
Lesezeichen