I have an array of items(image urls) in an array, i need it to display 5 at a time on the click of a button. I currently have it displaying the first 5:
edit: Only 5 must be loaded in the DOM on page load, then the next 5 on click etc
$smallSlides = '';
if (isset($backgrounds) && !empty($backgrounds)){
foreach ($backgrounds as $bg) {
$smallSlides .= $bg->getVersion()->getRelativePath() .', ';
}
}
$smallSlides = explode(',', $smallSlides);
<div class="small-slider">
<ul id="gallery" class="gallery">
<?php
$numSlidesCount = count($smallSlides);
$items = 5;
for ($i = 0; $i < $items; $i++) { ?>
<?php ?>
<li><a href="<?php echo $smallSlides[$i]; ?>" rel="external"><img src="<?php echo $smallSlides[$i]; ?>"></a></li>
<?php } ?>
</ul>
<button>Click for more</button>
</div>
So on page load it displays the first 5 images, then when the user clicks the show more button it shows the next 5 underneath untill there are no more images to display.