Jump to main content

Boolean

The idea of the boolean snippet is to present the website author with a short text element. Typing the word 'true' or 'false' within the short text element controls the display of content between the two PHP tags. Therefore it provides a simple approach towards toggling sections of a webpage on and off. The field name of this snippet is set at the start of the PHP (in this example it's called 'True / False Switch'), so it can be shared between both the WebYep short text element and our conditional logic. Of course, you can test against any comparison operator.

Example

This content only shows when the short text element is set to 'true' in the editing interface.

HTML & PHP

<?php
  $fieldName = "True / False Switch";
  if (webyep_bIsEditMode()) {
    webyep_shortText($fieldName, false, 550, 240);
  }
  if (webyep_bIsEditMode() || ((webyep_sShortTextContent($fieldName, false) === 'true'))) {
?>

<strong>
This content only shows when the short text element is set to 'true' in the editing interface.
</strong>

<?php } ?>

CSS

Javascript