USING IF STATEMENTS AND RECORD COUNTS TO CHANGE PAGE CONTENTS - Nov 25th, 2010


I recently had an artist client who’s portfolios were set up to show a list page of portfolio categories, a thumbnail
page showing all of the images that belonged to a particular category, and a detail page that showed details about
specific images.

They wanted to be able to link visitors directly to a thumbnail page if there was only one category in their portfolio,
and to show the list page only if there was more than one category.

I was able to easily accomplish their goal by counting the visible records in the portfolio category section. (If
records were "hidden" they were not counted.)

The portfolio categories were listed in a section called, “portfolio_name_details”, and a thumbnail page was called,
"portfolio_album.php"

I inserted the following code in the "Portfolio" link of the navigation menu:



<a href="<?php if ($portfolio_name_detailsMetaData['totalRecords'] == 1): ?>portfolio_album.php<?php else:
?>portfolio.php<?php endif ?>">Portfolio</a>


You can use the same approach to change the page content and perform other tasks.

NOTE: Don't forget to include the record count table in on each viewer's "get records" call. Mine looked like this:



list($portfolio_name_detailsRecords, $portfolio_name_detailsMetaData) = getRecords(array(
'tableName' => 'portfolio_name_details',
));




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