• Resolved chzumbrunnen

    (@chzumbrunnen)


    What would be the best practices to output some blocks only if the custom field (that I want to output within a HTML block) is not empty?

    Example:

    <div class="content-col content-col-4 last">
     <div class="productprice"><?php echo CFS()->get('productprice'); ?></div>
     <p class="priceoption"><?php echo CFS()->get('priceoption'); ?></p>
     <br />
      <a class="button align-right" href="<?php echo CFS()->get('order_url'); ?>"><?php echo CFS()->get('btn_text'); ?></a><br />
     </div>

    If productprice is empty the whole div-block should not be outputted.

    So I guess, I could do something like

    <?php
    if (!empty(CFS()->get('productprice'))) {
    ?>
          <div class="content-col content-col-4 last">
            <div class="productprice"><?php echo CFS()->get('productprice'); ?></div>
            <p class="priceoption"><?php echo CFS()->get('priceoption'); ?></p>
            <br />
            <a class="button align-right" href="<?php echo CFS()->get('order_url'); ?>"><?php echo CFS()->get('btn_text'); ?></a><br />
          </div> <!-- .second-col -->
    <?php
    }
    ?>

    But would this considered the right way to do it?

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

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Conditional output’ is closed to new replies.