Showing multiple sections on one main viewer page
3 posts by 3 authors in: Forums > CMS Builder
Last Post: June 12, 2013 (RSS)
By wevolutions - June 11, 2013
I have a regular section and a premium section on my website. I want to show regular ads plus premium ads on one viewer page but the premium ads must be on top of the regular ads. Any assistance will be appreciated. Thank you.
By gkornbluth - June 12, 2013 - edited: June 12, 2013
Hi arifkhayam,
I'm assuming that you are using multi-record sections for bot the regular and premium ads
If you load the records for both section editors at the top of your viewer, you can place the code for each wherever you want them to appear on your viewer.
So, for example, if each editor had only one text field...
<?php foreach ($premiumRecords as $record): ?>
<?php echo htmlencode($record['your_premium_text_field']) ?>
<?php endforeach ?>
Would show the text information in your_premium_text_field for all premium ads, and
<?php foreach ($regularRecords as $record): ?>
<?php echo htmlencode($record['your_regular_text_field']) ?>
<?php endforeach ?>
Would show the text information in your_regular_text_field for all regular ads.
You can place the foreach loops anywhere on your viewer and that is where the information will appear.
Of course, you'll probably have more than one field in your real section editors.
The code generator in the admin section of your CMS Builder interface will show the code required to show all of the fields that you are using.
This is a really simple implementation example, but there's lots more information about creating complex web pages how to limit which records will be seen on those pages in my CMSB Cookbook at http://www.thecmsbcookbook.com
Hope that helps,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
By gregThomas - June 12, 2013
Hi,
You should just be able to include two getRecord functions at the top of your page and display the premium adds first, for example your getRecord functions might look like this:
// load records from 'add'
list($normalAdds, $addMetaData) = getRecords(array(
'tableName' => 'normal_add_section',
'loadUploads' => true,
'allowSearch' => false,
));
// load records from 'add'
list($premiumAdds, $addMetaData) = getRecords(array(
'tableName' => 'premium_add_section',
'loadUploads' => true,
'allowSearch' => false,
));
Then you'd be able to display the content from each section like this:
<?php foreach($premiumAdds as $add):?>
<!-- premium content fields here -->
<p><?php echo $add['title']; ?></p>
<?php endforeach; ?>
<?php foreach($normalAdds as $add):?>
<!-- normal content fields here -->
<p><?php echo $add['title']; ?></p>
<?php endforeach; ?>
This is just example code, so you'll have to make a few changes to get it working.
So the two getRecords functions will retrieve the data from the premium and regular ads sections, you'll need to change the section names to match what you've used in your CMS.
Then on the part of the page where you want to display your ads you need to cycle through each of the ad arrays using a foreach loop to display their content.
Let me know if you have any questions.
Thanks!
Greg
PHP Programmer - interactivetools.com