How to display certain design elements only if field completed
4 posts by 2 authors in: Forums > CMS Builder
Last Post: June 20, 2008 (RSS)
By dwellingproductions - June 20, 2008 - edited: June 20, 2008
I want to find out how I can have certain HTML design elements and/or text only show up if a field is completed by the person adding information to the site using the CMS site editor.
For instance, in the following code:
Title: <?php echo $newsRecord['title'] ?><br>
I only want "Title:" to appear on the page if the person adding content to the site has filled in the "title" field. Otherwise, if they leave the field blank, I want to make sure that "Title:" doesn't appear on the page with nothing after it.
Similarly, I'd like to make sure that other design elements only appear if a field is utilized. In this example, I would want the line break to only show up if the field was used. That way, if I had several non-completed fields, I wouldn't end up with a bunch of extra space (line breaks) before the later content. Obviously, what I'm trying to do is automate the process so that the person updating the site doesn't have to mess with trying to fill code into the fields.
Hopefully that all makes sense. Thanks, in advance, for any assistance.
Dwelling Productions
www.dwellingproductions.com
Re: [dwelling] How to display certain design elements only if field completed
By Dave - June 20, 2008
I'd start by experimenting with the php if tag:
<?php if ($newsRecord['title']): ?>
Title: <?php echo $newsRecord['title'] ?><br>
<?php endif; ?>
Basically you just put the field you want to test in between the brackets (in red). Note that this won't display for blank -or- zero.
Give that a try and let me know if you need any assistance with it or if you need something more advanced and I'll do my best to help you out. :)
interactivetools.com
Re: [Dave] How to display certain design elements only if field completed
By dwellingproductions - June 20, 2008 - edited: June 20, 2008
By the way, we're loving CMS Builder. We're planning on integrating it into all future client sites. Keep up the great work!
Jeremy
Dwelling Productions
www.dwellingproductions.com
Re: [dwelling] How to display certain design elements only if field completed
By Dave - June 20, 2008
interactivetools.com