Hi zusammen!
Weiss jemand zufällig, wie man am besten die Anzahl der Bilder einer Bildgallerie herausfindet? Hintergrund: Ich will in verschiedenen Content-Gallerien je nach Anzahl der Bilder eine individuelle CSS Klasse hinzufügen, um die Bilder je nach Anzahl anders darzustellen. Momentan hab ich das so wie unten gelöst, was auch funktioniert. Aber diese doppelte foreach-Schleife möchte ich eigentlich vermeiden. Die Template Variable numberOfItems gibt leider nicht die tatsächliche Bildanzahl aus, sondern nur die maximale Anzahl der Bilder in den Gallerie-Einstellungen...

Also hier, was ich bisher habe:

Template: gallery_default.html5

Code:
<?php 
// Anzahl der verwendeten Bilder
$i=0;
?>
<?php foreach ($this->body as $class=>$row): ?>
    <?php foreach ($row as $col): ?>
      <?php if ($col->addImage): ?>
	  <?php $i++;?>
      <?php endif; ?>
    <?php endforeach; ?>
<?php endforeach; ?>	  

<?php //css Klasse "imganzahl" $i an ul anhängen ;?>

<ul class="cols_<?php echo $this->perRow; ?> imganzahl<?php echo($i);?>">
  <?php foreach ($this->body as $class=>$row): ?>
    <?php foreach ($row as $col): ?>
      <?php if ($col->addImage): ?>
	  <?php $i++;?>
        <li class="<?php echo $class; ?> <?php echo $col->class; ?>">
          <figure class="image_container"<?php if ($col->margin): ?> style="<?php echo $col->margin; ?>"<?php endif; ?>>
            <?php if ($col->href): ?>
              <a href="<?php echo $col->href; ?>"<?php echo $col->attributes; ?> title="<?php echo $col->alt; ?>"><?php $this->insert('picture_default', $col->picture); ?></a>
            <?php else: ?>
              <?php $this->insert('picture_default', $col->picture); ?>
            <?php endif; ?>
            <?php if ($col->caption): ?>
              <figcaption class="caption"><?php echo $col->caption; ?></figcaption>
            <?php endif; ?>
          </figure>
        </li>
      <?php endif; ?>
    <?php endforeach; ?>
  <?php endforeach; ?>
</ul>