Kommentare nummerieren

Aus Contao Community Documentation

Version vom 8. Januar 2012, 23:36 Uhr von Do while (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)


MsgError.png Unvollständiger Artikel: dieser Artikel ist noch nicht sauber bearbeitet.

Bitte erweitere ihn und entferne erst anschliessend diesen Hinweis.


Kommentare nummerieren

Im Forum wurde die Frage diskutiert, wie man Kommentare durchnummerieren kann. Wenn man alle Bedingungen abprüfen will, die die Ausgabe beeinflussen können, ist es nicht ganz so trivial.

Die Kommentare werden über das Template ce_comments.html5 (bzw. .xhtml, .tpl) ausgegeben. Um die Ausgabe zu verändern, erstellt man über das Template-Menü eine Kopie im templates-Ordner.

Der Anfang des Templates ist dann wie folgt anzupassen:

<?php
$this->import('Database');
$objComments = $this->Database->prepare("SELECT COUNT(*) AS anzahl FROM tl_comments WHERE published=1 AND parent=?")->execute($this->id);
$ofs = $this->com_perPage * (is_numeric($this->Input->get('page')) ? $this->Input->get('page')-1 : 0);
?>
 
<div class="<?php echo $this->class; ?> block"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
<?php if ($this->headline): ?>
 
<<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
<?php endif; ?>
<?php
  $cnt = $this->com_order == ascending ? 1+$ofs : $objComments->anzahl - $ofs;
  foreach ($this->comments as $comment) {
    echo 'Kommentar ' . $cnt . ' von ' . $objComments->anzahl . '<br>';
    echo $comment;
    $cnt += $this->com_order == ascending ? 1 : -1;
  }
?>
<?php echo $this->pagination; ?>
<?php if (!$this->requireLogin): ?>
  .
  .
  .



Erstellt von: do_while

Ansichten
Meine Werkzeuge

Contao Community Documentation

Das hier ist eine abstrakte Konversation

Marc A. Harnos
Navigation
Verstehen
Verwenden
Entwickeln
Verschiedenes
Werkzeuge