Um euch eine Lösung nicht vorzuenthalten, hier ein (noch) inoffizieller minimal-eingriff, der es ermöglicht verknüpfte Kataloge/ Tabellen im Backend via Format-String anzuzeigen.
Und zwar gibt man der function generateTitle in der Catalog.php des Catalog-Moduls auf Zeile 782:
PHP-Code:
private function generateTitle($strFormat, $values, $tableName, $row)
die ergänzende $row-Var, und darin dem switch:
PHP-Code:
case 'select':
$replace = $fieldConf['options'][$row[$params[0]]];
break;
Darüber, beim Aufruf der Methode durch die
PHP-Code:
public function renderField($row)
auf Zeile 777, kommt noch eine var dazu:
PHP-Code:
return $this->generateTitle($strFormat, $values, $tableName, $row);
Aufgerufen wird dann mit
Code:
{{fieldname::relatedValue}}
nochmal die beiden geänderten Methoden in Gänze:
PHP-Code:
/**
* Row Label
*/
public function renderField($row)
{
if (!$row['pid'])
{
return 'ID:'.$row['id'];
}
if (isset($this->tableNames[$row['pid']]) && isset($this->strFormat[$row['pid']]))
{
$tableName = $this->tableNames[$row['pid']];
$strFormat = $this->strFormat[$row['pid']];
}
else
{
$objType = $this->Database->prepare("SELECT tableName, format FROM tl_catalog_types WHERE id=?")
->limit(1)
->execute($row['pid']);
$tableName = $objType->tableName;
$strFormat = $objType->format;
$this->tableNames[$row['pid']] = $tableName;
$this->strFormat[$row['pid']] = $strFormat;
}
$fields = $GLOBALS['TL_DCA'][$tableName]['list']['label']['fields'];
$values = array();
foreach($fields as $field)
{
$values[$field] = $this->formatTitle($row[$field], $GLOBALS['TL_DCA'][$tableName]['fields'][$field]);
}
if (!strlen($strFormat))
{
return implode(', ', $values);
}
else
{
return $this->generateTitle($strFormat, $values, $tableName, $row);
}
}
private function generateTitle($strFormat, $values, $tableName, $row)
{
$fields = $GLOBALS['TL_DCA'][$tableName]['list']['label']['fields'];
preg_match_all('/{{([^}]+)}}/', $strFormat, $matches);
//$strFormat = '';
foreach ($matches[1] as $match)
{
$params = split('::', $match);
$fieldConf = $GLOBALS['TL_DCA'][$tableName]['fields'][$params[0]];
if ($fieldConf)
{
$replace = $values[$params[0]];
if ($params[1])
{
switch ($fieldConf['eval']['catalog']['type'])
{
case 'file':
if ($fieldConf['eval']['catalog']['showImage'])
{
$replace = $this->generateThumbnail($replace, $params[1], $fieldConf['label'][0]);
}
break;
case 'checkbox':
// only use image if checkbox == true
$replace = ($replace ? $this->generateThumbnail($replace, $params[1], $fieldConf['label'][0]) : '');
break;
case 'select':
$replace = $fieldConf['options'][$row[$params[0]]];
break;
default:;
}
}
$strFormat = str_replace('{{'.$match.'}}', $replace, $strFormat);
}
}
return $strFormat;
}
Lesezeichen