Modul-ID anzeigen im Backend
Hallo,
in diesem Beitrag aus dem Contao-Forum findet man eine tolle Möglichkeit, Artikel- bzw. Seiten-IDs im Backend darzustellen.
Allerdings gibt es ein Anzeigeproblem für Modul-IDs seit Contao 2.9.0.
Kann mir da jemand einen Tipp geben, wie man folgende Zeile modifizieren kann, um die Modul-ID in allen Themes anzeigen zu lassen?
Code:
/*
* Show module id
*/
$GLOBALS['TL_DCA']['tl_module']['list']['label']['fields'][] = 'id';
$GLOBALS['TL_DCA']['tl_module']['list']['label']['format'] = '%s <span style="color: #A3A3A3; padding-left: 3px;">[%s, ID: %s]</span>';
Merci :)
Modul ID anzeigen in Übersicht in Contao 2.9.1
Ok, trage folgende Zeile in die dcaconfig.php ein:
PHP-Code:
$GLOBALS['TL_DCA']['tl_module']['list']['sorting']['child_record_callback'] = array('tl_moduleid', 'listModule');
Lege im Verzeichnis /system/modules ein neues an. z.b. "zzz_moduleid",
in /system/modules/zzz_moduleid legst du eine Datei an mit Namen "tl_moduleid.php" mit folgendem Inhalt:
PHP-Code:
<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');
/**
* Class tl_moduleid
* Add ID in the module list
*/
class tl_moduleid extends Backend
{
/**
* Import the back end user object
*/
public function __construct()
{
parent::__construct();
}
/**
* List a front end module
* @param array
* @return string
*/
public function listModule($row)
{
return '<div style="float:left;">'. $row['name'] .' <span style="color:#b3b3b3; padding-left:3px;">['
.$GLOBALS['TL_LANG']['FMD'][$row['type']][0] .']</span> (ID:' .$row['id']. ")</div>\n";
}
}
?>
Das ganze sieht dann so aus:
http://img5.imagebanana.com/img/19m8.../module_id.jpg
Edit: Wegen umbruch auf 2 Zeilen verteilt die Return Ausgabe, sollte alles in einer Zeile stehen
Liste der Anhänge anzeigen (Anzahl: 1)
Okay, ich hatte Deinen obigen Code im Template ..._full drin, nicht im ..._teaser. Da erscheint, was ich will, nur werde ich daraus nicht schlau:
Abfrage von dump($GLOBALS['TL_DCA']['tl_content']['fields']; ergibt:
Anhang 22315
Wie gebe ich jetzt im DCA Feld einen Standard vor?
ToM