Jump to main content

Conditionals

As the person in charge of making your website editable, one of your tasks is to keep the 'edit mode' tidy and functioning correctly. Sometimes while the page is being edited, there could be items that get in the way or even cause the edit buttons to be lost. At other times, there might be special code or content you only want shown when someone is editing the page. Conditionals provide a simple mechanism towards regulating the control of code or content, depending on whether the page is in edit mode or not. The content to be hidden or shown goes between the two pairs of PHP tags. The flag can be changed between either true or false, depending on whether the content is to be shown in edit mode or not. Conditionals work anywhere in the page and for any type of code or content.

Example

I am only shown when the page is not in edit mode.

HTML & PHP

<?php if(webyep_bIsEditMode() == true) : ?>
  <strong>I get shown when the page is being edited.</strong>
<?php endif; ?>

<?php if(webyep_bIsEditMode() == false) : ?>
  <strong>I am only shown when the page is not it edit mode.</strong>
<?php endif; ?>

CSS

Javascript