Can I display only positive result content?

4 posts by 3 authors in: Forums > CMS Builder
Last Post: January 14, 2010   (RSS)

Hi all,

We are currently providing a facility for a client which displays information on used caravans much the same as instant realty, as with a realty application there are certain fields for facilities which each caravan may have ie double glazing, central heating etc, my client wants to know if it is possible for the detail listing for each caravan to only display facilities it has and omit the things it doesnt, for example if the caravan has double glazing then include double Glazing in the list but if it hasnt got central heating then to omit central heating from the list rather than listing Central Heating - No.

The intention being to not highlight the facilities a particular caravan may not have just focus on the positive items.

I am sure it will be possible but not sure how to go about it or how difficult this might be with my limited knowledge of both php and cms builder, any help would/advice would be appreciated.

Thanks in advance.

Re: [willydoit] Can I display only positive result content?

By Chris - January 8, 2010

Hi willydoit,

You can accomplish this with an IF block. For example, if your fields are "checkbox fields" and you are starting with this code in your page:

Central Heating - <?php echo $record['central_heating'] ?><br />

You can change that to this:

<?php if ($record['central_heating']): ?>
Central Heating - Yes<br />
<?php endif ?>


That HTML in the second line will only appear if your field is checked. You can add whatever HTML you want for that second line, such as an image. You'll need to make sure you get your field names (in red, above) correct.

If you're using "list fields" instead of checkboxes, please let me know and I'll show you some code for those.

I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [depdesign] Can I display only positive result content?

By Chris - January 14, 2010

Hi depdesign,

For text fields and list fields, you can probably get away with:

<?php if (strlen($record['field_name'])): ?>
Field Name - <?php echo htmlspecialchars($record['field_name']) ?><br />
<?php endif ?>


Does that work for you? I hope this helps! :)
All the best,
Chris