Best way to display multiple sections on single page

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 27, 2011   (RSS)

Re: [trebien] Best way to display multiple sections on single page

By Jason - October 27, 2011

Hi,

The approach I would take would be to create a single record section that only had fields that were completely unique to the homepage. For example, you would probably have a "welcome" field.

You can then bring in records from other sections. For example, let's assume there is an about_us section, so we can retrieve that separately. There would also be a "news" section, where we can retrieve the latest couple of records.

Here is an example of how we would retrieve all 3 sections. Here we're assuming that welcome and about us are single record sections. News is a multi-record section and we're going to retrieve the first 3 records created most recently:

list($welcomeRecord, $welcomeMetaData) = getRecords(array(
'tableName' => 'welcome',
'allowSearch' => false,
'limit' => 1,
));

$welcome = @$welcomeRecord[0];

list($aboutUsRecord, $aboutUsMetaData) = getRecords(array(
'tableName' => 'about_us',
'allowSearch' => false,
'limit' => 1,
));

$aboutUs = @$aboutUsRecord[0];

list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'allowSearch' => false,
'limit' => 3,
'orderBy' => "createdDate DESC"
));


So at the end of this code we could output fields from the welcome section from the $welcome variable and from about_us from the $aboutUs variable. We can use a foreach loop to go through each of the $newsRecords records.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/