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: [gkornbluth] Code to show records on only one listing page

OK. I have the page http://www.axislighting.com/CMS/brandsList-downloads.php

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

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

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

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

Thanks Jason.

Worked like a gem. Just what I needed.