Can I display only positive result content?

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

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: [chris] Can I display only positive result content?

Thanks!!! This post helped me greatly! Thanks
I am also interested as to how I can do the same if i am using
• a dropdown list
• a text field (if there is text entered it is displayed and if left blank does not display.

Thanks again.[:)]
Dan Perez

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