Help with setting up if then conditions

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 15, 2008   (RSS)

Yet again I find myself needing a bit of help.

Here’s what I’ve done:

I’ve set up a multi record section editor and have included a pull down list field with a list of categories. IE: “book, CD, Magazine, etc. (BTW, what’s the difference between a simple pull down list and a multi value pull down list?)

Here’s what I’m trying to do:

On my details page, if the group_code of the particular record is “book” then I would like to display field “A”, if it’s “CD” I’d like to display field “B”, if it’s “magazine” I’d like to display field “C”, and if it’s none of those I’d like to display field “D”.

I’ve looked around on the forum but I’m still a bit confused.

Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Help with setting up if then conditions

By Dave - November 14, 2008

Hi Jerry,

>what’s the difference between a simple pull down list and a multi value pull down list?

If you hold down ctrl you can select multiple values in a multi value pull down list.

Try this for your if code, I'll assume group_code is $record['group_code'] but just use whatever variable you have:

<?php if ($record['group_code'] == "book"): ?>
<?php echo $record['fieldA'] ?>
<?php else if ($record['group_code'] == "CD"): ?>
<?php echo $record['fieldB'] ?>
<?php else if ($record['group_code'] == "Magazine"): ?>
<?php echo $record['fieldC'] ?>
<?php else: ?>
<?php echo $record['fieldD'] ?>
Sorry, couldn't find a match for '<?php echo $record['group_code'] ?>'
<?php endif ?>


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com