• Resolved stevehtz

    (@stevehtz)


    Hi Matt,

    Thanks for the great plug-in!

    I would like to have the code in the template display only if a select field contains a certain value. There are two types of members to display: Staff Members and Board Members. The user can choose from a select box which type that each Team Member is. In this sample code I am trying to display only the Team Members which are chosen as Board Members from the select box.

    I know that the problem has something to do with the fact that select boxes output arrays, but I have not been able to figure it out beyond that.

    <?php
              $loop = CFS()->get('members');
              foreach ( $loop as $row ) {
                if ($row['type'] == 'Board Member') {
                ?>
                  <div class="member">
                    <div class="image">
                      <img src="<?php echo $row['avatar']; ?>" alt="">
                    </div>
                    <div class="member-label">
                      <h4><?php echo $row['name']; ?></h4>
                      <p><?php echo $row['position']; ?></p>
                    </div>
                  </div>
                <?php
                }
              }
            ?>

    Thank you so much for your help!

    https://www.ads-software.com/plugins/custom-field-suite/

Viewing 2 replies - 1 through 2 (of 2 total)
  • try this..

    <select name="agama" id="agama">
    <?php
    $agamas = array('apple', 'banana', 'pineapple', 'orange', 'grapes');
    foreach ($agamas as $agama) {
          $selected = ($rows['agama'] === $agama) ? ' selected="selected"' : '';
    ?>
        <option value="apple"<?php echo $selected; ?>>apple</option>
    <?php
    }
    ?>
    </select>

    Plugin Author Matt Gibbs

    (@mgibbs189)

    Thanks @tskamath

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Conditional display based on Select’ is closed to new replies.