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

I have a site that shows brochures for the brands listing page:

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

Hi dccreatives,

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
The first CMS Builder reference book is now available on-line!







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

Brochures is not a checkbox, it is a textfield. The checkbox is if it should be displayed on the brochures page or not.

Re: [dccreatives] Code to show records on only one listing page

By gkornbluth - July 5, 2012 - edited: July 5, 2012

OK, I assume both fields are in the same editor?

If so, you should be able to substitute the name of the check box field for 'brochure'

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [dccreatives] Code to show records on only one listing page

By gkornbluth - July 18, 2012

It normally would go just inside your foreach loop

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







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

I tried that, but it did not work. I got an error 500.

Re: [dccreatives] Code to show records on only one listing page

By Jason - July 18, 2012

Hi,

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

Thanks Jason.

Worked like a gem. Just what I needed.