Catalog Steuern der Kommentarfunktion abhaengig vom Wert eines Catalog feldes
Aus Contao Community Documentation
Version vom 5. Februar 2012, 13:23 Uhr von M3ph (Diskussion | Beiträge)
Problem
Die Kommentare und Kommentarfunktion soll nur angezeigt werden, wenn das Feld eines Items einen bestimmten Wert hat.
Der Inhalt des Readers wird in mod_catalogreader.tpl (View) bzw. die Detailinhalte in catalog_full.tpl (Partial) erstellt. Im mod_catalogreader.tpl sind die einzelnen Felder jedoch nicht als Variablen vorhanden.
Wie kann man Variablen zwischen den Templates übergeben?
mögliche Lösung
Speicherung der Variablen in Globals in catalog_full.tpl:
<?php if (count($this->entries)): ?> <div class="layout_full"> <?php foreach ($this->entries as $entry): ?> <div class="item<?php echo $entry['class'] ? ' '.$entry['class'] : ''; ?>"> <?php if($entry['linkEdit']): ?><?php echo $entry['linkEdit']; ?><?php endif; ?> <?php //save state of field Typ for using it in template mod_catalogreader.tpl $GLOBALS['Type_of_Item'] = $entry['data']['Typ']['value'];?> ....
Prüfen des Wertes in mod_catalogreader.tpl
... <?php if ($this->allowComments and $GLOBALS['Type_of_Item']=='Wert1'): ?> ...