Support

Account

Home Forums Add-ons Flexible Content Field true/false in a repeater in a flexible field

Helping

true/false in a repeater in a flexible field

  • I have a flexible field with a repeater in it. In the repeater, I have a true/false field. How would I add the word “heading” as a class if the value is true. So it would look like <tr class=”heading”>
    Below is an example of my code.

    
    <?php $drink = 25; ?>
    <!-- ///////////////////////////////////////////////   DRINK LIST -->
    <?php while(has_sub_field("menu_items", $drink)): ?>
    <?php if(get_row_layout() == 'drink_items'): ?>
    <?php if (get_sub_field('category')){?><?php the_sub_field('category');?><?php } ?>
    <?php if(get_sub_field("items")): ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <?php foreach(get_sub_field("items") as $x): ?>
    <tr class="IF TRUE ADD THE WORD HEADING">
    <td valign="top" style="width: 25%"><?php echo $x['name']; ?></td>
    <td valign="top" style="width: 65%"><?php echo $x['abv']; ?></td>
    <td valign="top" style="width: 5%"><?php echo $x['desc_1']; ?></td>
    <td valign="top" style="width: 5%"><?php echo $x['desc_2']; ?></td>
    <td valign="top" style="width: 5%"><?php echo $x['price_1']; ?></td>
    <td valign="top" style="width: 5%"><?php echo $x['price_2']; ?></td>
    </tr>
    <?php endforeach; ?>
    </table>
    <?php endif; ?>
    <?php endif; ?>
    <?php endwhile; ?>
    
  • Hi @theshae

    Something like this should work:

    
    <tr class="<?php if( $x['true_false_field'] ){ echo 'heading'; } ?>">
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘true/false in a repeater in a flexible field’ is closed to new replies.