Is there a way to use If Then simply?

10 posts by 4 authors in: Forums > CMS Builder
Last Post: October 14, 2009   (RSS)

By Moonworks - August 6, 2009

Is there a simple way to use soemthing like If Then statements?

For example, I want to show only sections that have been filled in.

The best example would be that if somebody was asked for their first, middle and last name and there was a section on the created page like this:

First:
Middle:
Last:

If they did not fill in a section for middle name, that line wouldn't show up, so the result would just show:

First:
Last:

I have various sections to be filled in, but not all of them will be used. I don't want to have a blank space where they would show up if filled in.
High quality residential training for writers, actors & Film Making - Click Here for further information

Re: [Moonworks] Is there a way to use If Then simply?

By Chris - August 6, 2009 - edited: August 6, 2009

Hi Moonworks,

There certainly is! In your viewer code, wrap the HTML you want to make optional with the following PHP code:

<?php if ($record['middle']): ?>
Middle: <?php echo $record['middle'] ?><br/>
<?php endif ?>


Voila!

Please let us know if you have any more questions!
All the best,
Chris

Re: [chris] Is there a way to use If Then simply?

By Moonworks - August 8, 2009

Thanks, that was painless [:)]
High quality residential training for writers, actors &amp; Film Making - Click Here for further information

Re: [benedict] Is there a way to use If Then simply?

By Chris - October 8, 2009

Hi benedict,

Would this do the trick?

<?php if ($short_course_calendarRecords): ?>
<?php echo date("D j M Y", strtotime($record['course_date'])) ?>
<?php elseif ($record['course_type'] == "Short Courses For Kids" || $record['course_type'] == "Short Course For Adults"): ?>
Please contact us for the next available course
<?php endif ?>


Hope this helps!
All the best,
Chris

Re: [chris] Is there a way to use If Then simply?

By benedict - October 8, 2009

Hi Chris,

Not quite. Nothing appears using this command for a Short Courses For Adults course.

I have attached my page to this post - your new entry is on line 240 and the commencement of the issue is at line 181.

Thanks for any help you an give.
Attachments:

hospitalitydetail.php 21K

Re: [benedict] Is there a way to use If Then simply?

By Damon - October 10, 2009

Hmm...the code Chris provided should work. We will need to take a closer look at the admin and the actual published page.

Can you send in a support request with:
- your CMS Builder login details,
- URL for the published page
- and link to this forum post wih the page code attached
https://www.interactivetools.com/support/email_support.cgi
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] Is there a way to use If Then simply?

By Chris - October 11, 2009

Hi benedict,

Courses or Course? Is this problem simply a typo? :)

either "Short Courses For Kids" or "Short Course For Adults"


elseif ($record['course_type'] == "Short Courses For Kids" || $record['course_type'] == "Short Course For Adults"):


Nothing appears using this command for a Short Courses For Adults course.

All the best,
Chris

Re: [chris] Is there a way to use If Then simply?

Yes, you were right. Thanks guys.

Re: [benedict] Is there a way to use If Then simply?

By Chris - October 14, 2009

Hi benedict,

Good to hear you got this sorted out! :)
All the best,
Chris