LIMITING THE NUMBER OF IMAGES ON A PAGE AND SHOWING CODE IF EXCEEDED - Aug 3rd, 2010


I wanted to show only a certain number of thumbnails on a page (20) and display a link to a second page if that number
was exceeded. The limit part was easy. In the get records code at the top of the page I entered



'limit' => '20',



To display the code if the number was exceeded, (in this case a link to a second viewer) I used the following: ( I was
already using a counter on this page so I called this counter count2)



<?php $count2 = 0; ?>
<?php foreach ($portfolio_imagesRecords as $record): ?>
<?php $count2++; ?>
<?php endforeach; ?>

<?php if ($count2 >19): ?><a href=”http://www.your_site.com/your_viewer2.php”>Click for more images.><?php endif ?>



You could also use this approach to display different messages:


<?php $count2 = 0; ?>
<?php foreach ($portfolio_imagesRecords as $record): ?>
<?php $count2++; ?>
<?php endforeach; ?>

<?php echo $count2>19 ? "There are over the maximum number of thumbnails" : "You cannot add more thumbnails" ; ?>




The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service