<r:if />

Renders a block of content only if a set of conditions are met or not met. <r:if> renders its content if the conditions are true. <r:if_not> renders its content if the conditions are false. The options are the same for both.

Attribute Options

value1 (v1) - The first value to be in the comparison. Its value can be hard coded or come from a page attribute, custom page attribute, variable set within your theme/template, a URL query parameter, or even a page content region.

value2 (v2) - The second value to be in the comparison. Its value can be hard coded or come from a page attribute, custom page attribute, variable set within your theme/template, a URL query parameter, or even a page content region.

operator (op) - The operator to use to compare value1 to value2. Can be one of: =, !=, >, <, >=, <=.

type - The type of value represented by value1 and value2. Can be one of: String (default), Number, Date, Boolean

Examples

<r:if value1="{page:name}" value2="Special" operator="=">
  <strong>This is a special page!!!</strong>
</r:if>
<r:if v1="{$some_variable}" v2="3.45" op=">" type="Number">
  Rendered if value1, which comes from a variable, is greater than 3.45, when treated as a Number.
</r:if>
<r:if v1="now" v2="8:00 AM" op=">" type="Date">
  <r:if v1="now" v2="5:00 PM" op="<" type="Date">
     <strong>Displayed between 8 AM and 5 PM daily.</strong>
  </r:if>
</r:if>

NOTE: Variable names in <r:if> statements must not contain minus (-) characters. Replace minus characters with underscores (_) or camelCase variable names.

Last updated on August 12, 2015.

We welcome all questions, feedback and bug reports. If you're having an issue, we usually need the following information:

  • A brief description of the issue
  • A link to the page where you saw the issue
  • Screenshots that illustrate the problem - How do I take a screenshot?

Kindly email CleanSlate@mail.wvu.edu for help or use the form on the request help page.