DISPLAY INFORMATION FROM MORE THAN ONE SECTION IN A SINGLE VIEWER - Aug 2nd, 2010


Setting up a page to display information from multiple sections is pretty easy once you get the hang of it. But it can
be somewhat confusing at first.

Here’s the approach for displaying information on a home page from information that’‘s in a single record editor
called “homepage” and other information from a multi record editor called “listings”.

First you’ll need to set up the top of your page with getRecords calls to the two sections. (You can copy the actual
code from the code generated in the admin area of the CMSB interface)



<?php

require_once "/your path/cmsAdmin/lib/viewer_functions.php";

list(
$homepageRecords, $homepageMetaData) = getRecords(array(
'Table name' => 'homepage',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$homepageRecord = @$homepageRecords[0]; // get first record


list($yourlistingsRecords, $yourlistingsMetaData) = getRecords(array(
'Table name' => 'yourlistings',

));

?>



Then in the body where you want to display the home page information



<?php echo $homepageRecord['your_first_field'] ?><br />
<?php echo $homepageRecord['your_second_field'] ?><br />
<?php echo $homepageRecord['your_third_field'] ?>



and in the body where you want to display the listings records:



<?php foreach ($yourlistingsRecords as $record): ?>
<?php echo $record['your_first_field'] ?><br />
<?php echo $record['your_second_field'] ?><br />
<?php echo $record['your_third_field'] ?>
<?php endforeach; ?>



There’s no formatting in the above example, but it should get you started.

This concept can be expanded to display information pulled from any number of sections.

If you find you’re getting errors when you try to display items from a single record editor on multi record detail
pages, you may need to remove the:



'where' => whereRecordNumberInUrl(1),



from the get records call so that you can display them.

There are situations where you may have to remove the:



'limit' => '1',



as well.



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