hiding empty fields

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

By steve_e - March 2, 2010

Hi -
Is there a built-in CMS Builder way to automatically not show fields with no content in them, or do we need to do this ourselves with PHP? Can't see any option that says 'miss this line out if there's nothing in it' or something similar...'.

Re: [steve_e] hiding empty fields

By Chris - March 2, 2010

Hi steve_e,

You'll need to do this in PHP, but it's really quite easy. Simply replace this:

Field: <?php echo $record['field'] ?>

with this:

<?php if ($record['field']): ?>
Field: <?php echo $record['field'] ?>
<?php endif ?>


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

Re: [chris] hiding empty fields

By steve_e - March 3, 2010

Thanks Chris -
I just had a page with a whole bunch of possibly empty fields and the code was starting to look a little ragged with all the if statements, so I was wondering if I'd missed something in CMS B.

Might this be a good thing to include as a field option in a future release?