Simple Checkbox to display panels

2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 18, 2008   (RSS)

By avrom - July 18, 2008

Hi Dave,

I have a simple checkbox field in the editor sections to turn on and off the display of info boxes on the web page:

So if the record "info_box_1" is checked for a value of "1" I want to embed some code etc. I think this is most of what I need:

<?php if ($record['info_box_1']): ?>
Do html stuff here if info_box_1 = a value of 1
<?php endif ?>

Thanks Dave
Avrom

Re: [virgodesign] Simple Checkbox to display panels

By Dave - July 18, 2008

Hi Avrom,

Yes, that's pretty much it. Give it a try and let me know how it goes.

Some tips for you to help with debugging. If it's not working try printing out the value of the checkbox:

info_box_1: '<?php echo $record['info_box_1']?>'

If it's 0 or 1 you can use the code you have, if it's Yes or No you'll need to test like this:

<?php if ($record['info_box_1'] == 'Yes'): ?>

And if you want to see what all the field values are you can always use this:

<xmp><?php print_r($record) ?></xmp>

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