Specific records displaying question

5 posts by 4 authors in: Forums > CMS Builder
Last Post: August 22, 2008   (RSS)

By Codee - August 18, 2008 - edited: August 22, 2008

Hi Dave and Co,

I did a couple searches in the forum but did not yield the results I needed for this simple question.

What code would I use to have specific records or thumbnails to records show, ONLY if a certain field is checked in inventory.

Here's an "almost done" example. I have a "featured ad" scrolling section at the top of a site that works extremely well for pulling all first thumbnails out of inventory, and rotating them. When you click on a thumbnail in the featured ad scrolling section the details page for that specific record opens up. I built it by setting up a series of viewers inside some dynamic java script that simply rotates through each viewer on about 2 second intervals. So, every 2 seconds the next viewer replaces the one that's there and it runs continuously. It looks great. It works great. BUT it pulls from ALL the inventory. I need it to pull the data only from records in inventory that have the "featured ad" box checked.

Thanks in advance![crazy]

Re: [equinox69] Specific records displaying question

By Jake - August 19, 2008

Hi equinox69,

You should be able to set this up using a PHP if statement, like this:

<?php if ($yourRecord['featured_ad'] == "1"): ?>
***Record Display Code here***
<?php endif ?>


All you need to to is adjust that first line so that the correct field name is used, and the "$yourRecord" text is changed to correspond with your section's name.

Let us know how this works out!
-----------------------------------------------------------
Cheers,
Jake Marvin - Product Specialist
support@interactivetools.com

Hire me!
Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.

Re: [Jake] Specific records displaying question

By johnniefp - August 20, 2008 - edited: August 20, 2008

I'm new to CMSB but have been reading through to docs.

On this page:
http://www.interactivetools.com/docs/cmsbuilder/code_generator.html it shows you can filter results.

Wouldn't you be better off letting MySQL do the filtering? so in the 'Filter Results' textbox you enter 'featured_ad = 1'

edit:
using MySQL filtering assumes you only want 'featured_ad' results so this would only give you a filtered resultset.

Jakes solution will give you all the results and leave the logic up to you as to showing 'featured_ad'.

In short; Jakes solution is more flexible.

Re: [johnniefp] Specific records displaying question

By Dave - August 20, 2008

It depends on what's needed on the page but I think that's another good approach if none of the "non-featured" listings need to be displayed on the page.

Thanks for the suggestion!
Dave Edis - Senior Developer
interactivetools.com