Best way to display multiple sections on single page
2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 27, 2011 (RSS)
By trebien - October 27, 2011
Ok... we've searched around, and many posts are several years old regarding this functionality.
For a typical homepage, where there may be an "Welcome" blurb, and then some "News" listings, and an "About Us" area, and some other things... it gets messy to add all these fields into a single section editor, and then expect the client to easily manage them.
Should we set up different section editors for each "area" of the homepage? This seems intuitive, but also seems bulky, since there will be multiple section editors just for a single page.
I am sure this is a common question... but am curious at this point what is "best practices" for the most current version of CMSB?
Thanks.
For a typical homepage, where there may be an "Welcome" blurb, and then some "News" listings, and an "About Us" area, and some other things... it gets messy to add all these fields into a single section editor, and then expect the client to easily manage them.
Should we set up different section editors for each "area" of the homepage? This seems intuitive, but also seems bulky, since there will be multiple section editors just for a single page.
I am sure this is a common question... but am curious at this point what is "best practices" for the most current version of CMSB?
Thanks.
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:
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.
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/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/