If & Elseif Not Working Right & Confused
2 posts by 2 authors in: Forums > CMS Builder
Last Post: December 29, 2010 (RSS)
By Rusty - December 28, 2010
I have a multi-item list-view page.
Based upon selection from a drop down within the section editor for the Mutli Item list, I'm trying to get an image to show.
I have been successful in swapping CSS based up on a selection within a Single-Selection drop down.
When I try to show even text based upon selection of even a single item from the multi-select drop down, I get
I noticed the difference between how the fields are outputted:
Any hints or suggestions..
This is my test html...
Suggestions?
It would seem that it's getting hung up on the first $record['type']
Based upon selection from a drop down within the section editor for the Mutli Item list, I'm trying to get an image to show.
I have been successful in swapping CSS based up on a selection within a Single-Selection drop down.
When I try to show even text based upon selection of even a single item from the multi-select drop down, I get
Undefined variable: record
I noticed the difference between how the fields are outputted:
Series: <?php echo $record['series'] ?><br/>
Type: <?php echo join(', ', getListLabels('events_calendar', 'type', $record['type'])); ?><br/>
Any hints or suggestions..
This is my test html...
<div id="eventwrapper" style="background-color:#<?php if ($record['series'] == 'OMRA'):?>FFCC99
<?php elseif ($record['series'] == 'XC'):?>00FF00
<?php elseif ($record['series'] == 'GP'):?>FFFF00
<?php elseif ($record['series'] == 'DS'):?>00FFFF
<?php endif ?>">
asdf
<?php if ($record['type'] == 'Bike'):?>bike it is
<?php elseif ($record['type'] == 'ATV'):?>Quads are us
<?php elseif ($record['type'] == 'Dual-Sport'):?>Enduro ftw
<?php endif ?>
</div>
Suggestions?
It would seem that it's getting hung up on the first $record['type']
Rusty
Re: [Rusty] If & Elseif Not Working Right & Confused
By zip222 - December 29, 2010
I think you are missing the 'foreach'. if you go back to the original code that you got from code generator, you will see a foreach statement that needs to appear before you the any of the $record variables. you will also need to include the 'endforeach' after.
<?php foreach ($YOURSECTIONRecords as $record): ?>
and...
<?php endforeach ?>