Home | Products | Consulting | Hosting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
How to display certain design elements only if field completed

 

 


dwelling
User

Jun 20, 2008, 12:29 PM

Post #1 of 4 (214 views)
Shortcut
How to display certain design elements only if field completed Can't Post

Hello all. I'm new to the forums (and to CMS Builder) and have a quick question.

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.


(This post was edited by dwelling on Jun 20, 2008, 12:34 PM)


Dave
Staff / Moderator


Jun 20, 2008, 12:55 PM

Post #2 of 4 (207 views)
Shortcut
Re: [dwelling] How to display certain design elements only if field completed [In reply to] Can't Post

dwelling, welcome to the CMS Builder forum! :)

I'd start by experimenting with the php if tag:


Code
<?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. :)

Dave Edis - Senior Developer
interactivetools.com


dwelling
User

Jun 20, 2008, 1:10 PM

Post #3 of 4 (203 views)
Shortcut
Re: [Dave] How to display certain design elements only if field completed [In reply to] Can't Post

That's just perfect! Thanks so much Dave.

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


(This post was edited by dwelling on Jun 20, 2008, 1:11 PM)


Dave
Staff / Moderator


Jun 20, 2008, 1:31 PM

Post #4 of 4 (197 views)
Shortcut
Re: [dwelling] How to display certain design elements only if field completed [In reply to] Can't Post

Thanks, great to hear! If there's anything else you need just let me know! :)

Dave Edis - Senior Developer
interactivetools.com

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Hosting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4