Bitte mal testen:
ps. sind noch ein paar Kommentare etc. drin.
Und die Gesamtausgabe wird jetzt natürlich noch für jeden Katalog ausgegeben.
Das ändere ich dir nachher.
Aber im letzten Umlauf steht immer die Gesamtzahl.
schneller gings nicht.
PHP-Code:
<?php
/***
* Sample "View notelist" template file which get used to render a form in the frontend.
* This sample shows how to display the notelist form element.
* To see the data structure, uncomment the print_r()
*/
?>
<?php // print_r($this->items); ?>
<?php $actCatalogId = $this->items[0]['catId']; ?>
Aktueller Catalog: <?php echo $actCatalogId; ?>
<?php if($actCatalogId != oldCatalogId): ?>
Neuer Katalog: Einträge im letzten Katalog: <?php echo $GLOBALS['TL_LANG']['MSC']['my_catalognotelist']['oldCatalogCount']; ?>
<?php endif; ?>
<?php $itemCount = $GLOBALS['TL_LANG']['MSC']['my_catalognotelist']['oldCatalogCount']; ?>
<div class="formnotelist">
<?php if($this->description): ?>
<?php echo $this->description; ?>
<?php endif; ?>
<?php foreach($this->items as $item): ?>
<div class="notelistitem">
<?php echo $item['amount']; ?>
<?php foreach($item['fields'] as $k=>$field): ?>
<div class="field">
<span class="title"><?php echo $field['title']; ?></span>
<span class="value"><?php echo $field['value']['value']; ?></span>
</div>
<?php endforeach; ?>
<div class="notelistvariants">
<?php foreach($item['variants'] as $k=>$variant): ?>
<?php echo $variant['name']; ?>
<?php endforeach; ?>
</div>
<?php echo $item['input_amount']; ?>
<?php echo $item['input_update']; ?>
<?php echo $item['input_remove']; ?>
</div>
<?php $itemCount++; ?>
<?php endforeach; ?>
</div>
<?php $oldCatalog = $actCatalog; ?>
<?php $oldCatalogCount = $itemCount; ?>
<?php $total = $itemCount; ?>
<div class="total">Gemerkte Objekte: <?php echo $total; ?></div>
<?php $GLOBALS['TL_LANG']['MSC']['my_catalognotelist']['oldCatalogCount'] = $oldCatalogCount; ?>
<?php $GLOBALS['TL_LANG']['MSC']['my_catalognotelist']['total'] = $total; ?>
<?php setcookie("my_catalognotelist_total", "$total", time()+60*60); // 1 Stunde ?>
Ganz unten schreibe ich das noch in einen Cookie, damit man auch von anderen Seiten darauf zu greifen kann. Ist sehr rudimentär, aber funktioniert.
Den kannst du mit
PHP-Code:
Anzahl in Merkliste:
<?php echo $_COOKIE['my_catalognotelist_total']; ?>
auslesen.
Das updated sich jetzt auf der Seite mit dem Merkliste-Modul. Das muss man jetzt noch umbauen, dass es beim Absenden geupdated wird. Im Grunde sollte das noch einfacher sein, da man nur per Klick hochzählen muss bzw. beim Löschen abziehen - egal welcher Katalog.
Aber teste das oben erstmal, ob es in die richtige Richtung geht.
Lesezeichen