Checked list field displays an image - how to?

13 posts by 2 authors in: Forums > CMS Builder
Last Post: May 14, 2012   (RSS)

By csdesign - May 3, 2012

Hello!
I just setup a list field (radio buttons) with 3 options for a real estate listing. Options are Sold, Reduced & New. When the admin adds/updates a property they can tick the optional radio box indicating one of the three (sold, reduced or new).

Checking the box would result in a small banner being displayed with that property.

I understand it would be IF the radio box is ticked, THEN the banner displays but I definitely need help with the code for that. If no radio button is ticked, then no banner will display.

Not much of a start so far:

<?php echo $listing['banner_status'] ?>

Thanks so much!! Tina

Re: [gkornbluth] Checked list field displays an image - how to?

By csdesign - May 11, 2012

Thanks Jerry!

I've been hacking at this thing for awhile now and I get it close, but never perfect. I found a few more examples and tried to go from there, but again, no luck.

I'm hoping it's just something obvious I'm missing. Can you take a look please? As it is right now I had to remove it from the page because the page shows a complete blank when this code is added:

<?php foreach ($listingRecords as $record): ?>
<?php if ($record['banner_status'] == Sold) : ?><img src="http://www.dunhamrealestateservices.com/images/bnr-sold.jpg" width="312" height="25" /><?PHP endif ?>
<?php if ($record['banner_status'] == Reduced) : ?><img src="http://www.dunhamrealestateservices.com/images/bnr-reduced.jpg" width="312" height="25" /><?PHP endif ?>
<?php if ($record['banner_status'] == New) : ?><img src="http://www.dunhamrealestateservices.com/images/bnr-new-listing.jpg" width="312" height="25" /><?PHP endif ?>
<?php echo $record['banner_status'] ?>
<?php echo $record['banner_status'] ?>
<?php echo $record['banner_status'] ?>
<?php endforeach ?>


Thanks so much! Tina

Re: [csdesign] Checked list field displays an image - how to?

By gkornbluth - May 11, 2012

Hi tina,

I think if you put single quotes around 'Sold' 'Reduced' and 'New' it will solve the problem.

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] Checked list field displays an image - how to?

By csdesign - May 11, 2012

I'll give that a shot. Thanks!!

Re: [csdesign] Checked list field displays an image - how to?

By gkornbluth - May 11, 2012

Let me know if you need more help

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] Checked list field displays an image - how to?

By csdesign - May 11, 2012

Hi Jerry,

Well, maybe it's the week I'm having or it's just beyond my limited skills ;)

I tried a few variations on this but got the same result. The Image is now showing properly (yeah!) but now all listings are marked "new" when in reality, I only have one test property marked "new" at this moment.

Using this code:

<?php foreach ($listingRecords as $record): ?>
<?php if ($record['banner_status'] == 'Sold') : ?><img src="http://www.dunhamrealestateservices.com/images/bnr-sold.jpg" width="312" height="25" /><?PHP endif ?>
<?php if ($record['banner_status'] == 'Reduced') : ?><img src="http://www.dunhamrealestateservices.com/images/bnr-reduced.jpg" width="312" height="25" /><?PHP endif ?>
<?php if ($record['banner_status'] == 'New') : ?><img src="http://www.dunhamrealestateservices.com/images/bnr-new-listing.jpg" width="312" height="25" /><?PHP endif ?>
<?php endforeach ?>


I have a dummy image of the same dimension: bnr-none.png

I was trying to get it so if none are marked, then it would either display nothing or the dummy image, either one would be fine. My tests didn't work out.

Here's the listings page (all marked "NEW LISTING")
http://www.dunhamrealestateservices.com/listings.php?property_type=Residential

and my listingdetail page marked as "new"
http://www.dunhamrealestateservices.com/listingDetail.php?Condo-for-Sale-in-Red-Lodge-MT-38

(not sure about the definition of "condo" here... ) ;) So the listing detail page is fine. I even checked by changing it from "new" to "reduced" and "sold"... each time the new banner status carried over to the listings page as well.

Your help is much appreciated. Thanks again!!

Re: [csdesign] Checked list field displays an image - how to?

By gkornbluth - May 11, 2012

Hi Tina,

Looks like you're really close.

On the list page, insert the line: <br /><?php echo $record['banner_status'] ?><br /> in the loop before the <?php endforeach ?> and see what you get as the Banner Status for each record.

You can insert the line: <br /><?php echo $listingRecord['banner_status'] ?><br /> on the detail page to see what's being returned there as well.

That should give you a clue as to what's going on.

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] Checked list field displays an image - how to?

By csdesign - May 11, 2012

ha.. well, I'm not sure it gave ME a clue what's going on. ;)

listing page still has the same result, except now all of them also have the text entry of "new" also (under the 'new' image). I changed it to reduced and it changed across the board again.

http://www.dunhamrealestateservices.com/listings.php?property_type=Residential

I changed code to:

<?php foreach ($listingRecords as $record): ?>
<?php if ($record['banner_status'] == 'Sold') : ?><img src="http://www.dunhamrealestateservices.com/images/bnr-sold.jpg" width="312" height="25" /><?PHP endif ?>
<?php if ($record['banner_status'] == 'Reduced') : ?><img src="http://www.dunhamrealestateservices.com/images/bnr-reduced.jpg" width="312" height="25" /><?PHP endif ?>
<?php if ($record['banner_status'] == 'New') : ?><img src="http://www.dunhamrealestateservices.com/images/bnr-new-listing.jpg" width="312" height="25" /><?PHP endif ?>
<br /><?php echo $record['banner_status'] ?><br />
<?php endforeach ?>


I added the code into the listingDetail page too and got the error below so I removed it and reloaded it because the site is live.
http://www.dunhamrealestateservices.com/listingDetail.php?Condo-for-Sale-in-Red-Lodge-MT-38

Notice: Undefined variable: listingRecord in /hsphere/local/home/lyleandcindy/dunhamrealestateservices.com/listingDetail.php on line 113

I hope all of that made sense. :)

Re: [csdesign] Checked list field displays an image - how to?

By gkornbluth - May 12, 2012

Hi Tina,

Sorry that this is becoming so frustrating for you.

I also noticed that page 2 doesn't have any new image or "New" text.

Could you attach the list page and detail page viewers with the code inserted that gives you the error so I can see exactly what you're doing?

BTW: When working on a live site, you might want to copy the viewer you're working on and call it listinga.php. If you play with that one, your client won't see the changes until they're done.

You can do the same with the detail page, but you'd have to hard code the detail page link address (http://www.dunhamrealestateservices.com/listingDetaila.php) into the list page code because $record['_link'] will automatically pull up the original detail page.

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