contao/test — Issue #1188: Callback in dca/tl_comments.php
Author: importer
Created: 2011-11-29 07:29:30+00:00
State: open
Labels: comments, Feature

Hallo leo,
es waere schoen, wenn man fuer eigene Tabellen in system/modules/comments/dca/tl_comments.php Datei im switch Block ab Zeile 261 einen default haette, der einen user callback triggern kann.
Auf diese Weise kann ich dann vom Katalog aus ebenfalls einen entsprechenden Link auf meine Tabellen setzen.

den Callback stelle ich mir in etwa wie folgt vor:

```
public function onListComments($tablename, $parent)
{
if($tablename=='mycustomtable')
{
$objParent = $this->Database->prepare("SELECT id, title FROM tl_mymoduletable WHERE id=?")
->execute($parent);
return ' (' . $objParent->title . ')';
} else {
return false;
}
}
```

Den zugehoerigen Caller (system/modules/comments/dca/tl_comments.php ab Zeile 253 ff):

```
// [...]
case 'tl_calendar_events':
$objParent = $this->Database->prepare("SELECT id, title FROM tl_calendar_events WHERE id=?")
->execute($arrRow['parent']);

if ($objParent->numRows)
{
$title .= ' (' . $objParent->title . ')';
}
break;

default:
// HOOK: trigger callbacks for custom tables.
if (isset($GLOBALS['TL_HOOKS']['onListComments']) && is_array($GLOBALS['TL_HOOKS']['onListComments']))
{
foreach ($GLOBALS['TL_HOOKS']['onListComments'] as $callback)
{
$this->import($callback[0]);
$tmptitle = $this->$callback[0]->$callback[1]($arrRow['source'], $arrRow['parent']);
if(strlen($tmptitle))
{
$title .= $tmptitle;
break;
}
}
}
// [...]
```

--- _Originally created by xtra on November 23rd, 2009, at 10:07pm (ID 1188)_