Kommentare nummerieren

Aus Contao Community Documentation


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): ?>
  .
  .
  .

Der Rest des Templates bleibt Original.



Erstellt von: do_while

Ansichten
Meine Werkzeuge

Contao Community Documentation

Ich habe es mir mal grob ausgerechnet: Bei jeder Extension von mir verbrauche ich im Durchschnitt 6 Pizzen. Wenn Dir meine Extensions gefallen, sende mir bitte mehr Pizzen. Die Adresse gibt es auf Anfrage!

Leo Unglaub
Navigation
Verstehen
Verwenden
Entwickeln
Verschiedenes
Werkzeuge