please excuse this if its a duplicate or similar post, i have searched on here and could not figure out the answer to my question based on previous posts...
I know this may be a noob question (im trying desperately to teach myself php so please bear with me!)
I have a custom concrete5 block I am building (using jordanlev's awesome designer content).
Here is the code:
<?php if ($field_3_select_value == 1): ?>
<!-- ENTER MARKUP HERE FOR FIELD "Heading Placement Left or Right?" : CHOICE "head-left" -->
<?php endif; ?>
<?php if ($field_3_select_value == 2): ?>
<!-- ENTER MARKUP HERE FOR FIELD "Heading Placement Left or Right?" : CHOICE "head-right" -->
<?php endif; ?>
<?php if ($field_4_select_value == 1): ?>
<!-- ENTER MARKUP HERE FOR FIELD "Heading Placement - top middle bottom" : CHOICE "top" -->
<?php endif; ?>
<?php if ($field_4_select_value == 2): ?>
<!-- ENTER MARKUP HERE FOR FIELD "Heading Placement - top middle bottom" : CHOICE "middle" -->
<?php endif; ?>
<?php if ($field_4_select_value == 3): ?>
<!-- ENTER MARKUP HERE FOR FIELD "Heading Placement - top middle bottom" : CHOICE "bottom" -->
<?php endif; ?>
<div class="span 7 head <?php echo $field_3_select_value->$value; ?> <?php echo $field_4_select_value->$value; ?>">
<?php if (!empty($field_6_textbox_text)): ?>
<h2><?php echo htmlentities($field_6_textbox_text, ENT_QUOTES, APP_CHARSET); ?></h2>
<?php endif; ?>
<?php if (!empty($field_7_textbox_text)): ?>
<h2><?php echo htmlentities($field_7_textbox_text, ENT_QUOTES, APP_CHARSET); ?></h2>
<?php endif; ?>
<?php if (!empty($field_8_textbox_text)): ?>
<h2><?php echo htmlentities($field_8_textbox_text, ENT_QUOTES, APP_CHARSET); ?></h2>
<?php endif; ?>
What im trying to achieve is the value of $field_3_select_value
& $field_4_select_value
to appear as the content of the array in the class of the DIV.
Next up i have 3 text boxes that get inserted (if filled in by user) that is styled according to the classes on the div above.
Is this possible? Do i need to build a 'foreach' loop and if so, can someone help point me in the right direction? I would prefer to learn how to do this rather than just someone do it for me, so any help and any direction and of course any constructive criticism is greatly appreciated!
Thanks in advance :)
You can use switch
:
<?php
switch ($field_3_select_value):
case 1: $class3 = 'head-left'; break;
case 2: $class3 = 'head-right'; break;
default: $class3 = '';
endswitch;
switch ($field_4_select_value):
case 1: $class4 = 'top'; break;
case 2: $class4 = 'middle'; break;
case 3: $class4 = 'bottom'; break;
default: $class4 = '';
endswitch;
?>
<div class="span 7 head <?php echo $class3; ?> <?php echo $class4; ?>">