Code to show records on only one listing page
9 posts by 3 authors in: Forums > CMS Builder
Last Post: July 19, 2012 (RSS)
By dccreatives - July 5, 2012 - edited: July 5, 2012
http://axislighting.com/CMS/brandsList_brochure.php
I want to add some more brands and only want them visible on this page. (I use the brandsList listings on other pages as well.)
I added a section editor to the brands admin with a checkbox that says show only on brochure page.
I have a value called 'brochure'. I want that this brand should only show on the brochure page when checkbox is checked.
What would be the code that would show this brand only if the checkbox in the admin is checked?
Re: [dccreatives] Code to show records on only one listing page
By gkornbluth - July 5, 2012 - edited: July 5, 2012
If I understood your question correctly...
I assume that the brochures field is a check box. If so, could it be something like this that checks each record to only show those with the check box checked:
<?php foreach ($brandsRecords as $record ): ?>
<?php if( $record['brochure'] == 1):?>
Your listing code...
<?php endif ?>
<?php endforeach; ?>
There are lots of recipes in how to use if statements in my CMSB Cookbook thecmsbcookbook.com
Best,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Code to show records on only one listing page
By dccreatives - July 5, 2012
Re: [dccreatives] Code to show records on only one listing page
By gkornbluth - July 5, 2012 - edited: July 5, 2012
If so, you should be able to substitute the name of the check box field for 'brochure'
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Code to show records on only one listing page
By dccreatives - July 18, 2012
ON this page the top 7 listings, I do not want to show on this page, but I need them on other pages.
I created a checkbox that's field is 'show_only_on_brochure_page'. When this is checked, I do not want them to show on this page. I am attaching the html code. Can you tell me where to put the if then statement, so it should not show if this field is checked?
Thanks for all your help.
Re: [dccreatives] Code to show records on only one listing page
By gkornbluth - July 18, 2012
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Code to show records on only one listing page
By dccreatives - July 18, 2012
Re: [dccreatives] Code to show records on only one listing page
By Jason - July 18, 2012
You could filter them out directly in your getRecords call:
EXAMPLE
list($brandsRecords, $brandsMetaData) = getRecords(array(
'tableName' => 'brands',
'perPage' => '20',
'where' => "show_only_on_brochure_page != '1'"
));
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Code to show records on only one listing page
By dccreatives - July 19, 2012
Worked like a gem. Just what I needed.