Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Is there a way to use If Then simply?

 

 


Moonworks
User

Aug 6, 2009, 4:56 AM

Post #1 of 10 (1760 views)
Shortcut
Is there a way to use If Then simply? Can't Post

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.

[hr]  
High quality residential training for writers, actors & Film Making - [url "http://www.residentialtraining.co.uk"]Click Here[/url] for further information


Chris
Staff


Aug 6, 2009, 10:46 AM

Post #2 of 10 (1756 views)
Shortcut
Re: [Moonworks] Is there a way to use If Then simply? [In reply to] Can't Post

Hi Moonworks,

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


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


Voila!

Please let us know if you have any more questions!
Chris


(This post was edited by chris on Aug 6, 2009, 11:30 AM)


Moonworks
User

Aug 8, 2009, 4:43 PM

Post #3 of 10 (1739 views)
Shortcut
Re: [chris] Is there a way to use If Then simply? [In reply to] Can't Post

Thanks, that was painless Smile

[hr]  
High quality residential training for writers, actors & Film Making - [url "http://www.residentialtraining.co.uk"]Click Here[/url] for further information


benedict
User

Oct 7, 2009, 7:20 PM

Post #4 of 10 (1515 views)
Shortcut
Re: [Moonworks] Is there a way to use If Then simply? [In reply to] Can't Post

Hi Chris,

I have a follow up to this one:

I have a hospitality short course website.
The courses are entered in a section called "hospitality".
Course dates are entered in a "Short Course Calendar" section which pulls the courses from the "hospitality" section via a dropdown

This is all working fine. My problem is this:

I have a situation where the "course dates" section for a course should only show if there have been course dates entered in the "Short Course Calendar" section. So I have done this:


Code
<?php if ($short_course_calendarRecords): ?> 
<?php echo date("D j M Y", strtotime($record['course_date'])) ?>
<?php endif ?>


This works fine - but now I need to add a constraint that if the "course_type" in the "hospitality" section is either "Short Courses For Kids" or "Short Course For Adults", instead of not showing any dates, just to say "Please contact us for the next available course".

I guess I have never put 'where' criteria in the body of a page, only in the head so that's why I'm stumped.

Thanks for any help you can offer.


Chris
Staff


Oct 8, 2009, 3:41 PM

Post #5 of 10 (1501 views)
Shortcut
Re: [benedict] Is there a way to use If Then simply? [In reply to] Can't Post

Hi benedict,

Would this do the trick?


Code
<?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!
Chris


benedict
User

Oct 8, 2009, 6:17 PM

Post #6 of 10 (1497 views)
Shortcut
Re: [chris] Is there a way to use If Then simply? [In reply to] Can't Post

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 (19.7 KB)


Damon
Staff / Moderator


Oct 10, 2009, 9:11 PM

Post #7 of 10 (1483 views)
Shortcut
Re: [benedict] Is there a way to use If Then simply? [In reply to] Can't Post

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/


Chris
Staff


Oct 11, 2009, 1:59 PM

Post #8 of 10 (1464 views)
Shortcut
Re: [Damon] Is there a way to use If Then simply? [In reply to] Can't Post

Hi benedict,

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


In Reply To
either "Short Courses For Kids" or "Short Course For Adults"



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



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

Chris


benedict
User

Oct 14, 2009, 1:36 PM

Post #9 of 10 (1431 views)
Shortcut
Re: [chris] Is there a way to use If Then simply? [In reply to] Can't Post

Yes, you were right. Thanks guys.


Chris
Staff


Oct 14, 2009, 1:46 PM

Post #10 of 10 (1430 views)
Shortcut
Re: [benedict] Is there a way to use If Then simply? [In reply to] Can't Post

Hi benedict,

Good to hear you got this sorted out! :)
Chris