<r:page:if_has_content_for /> allows you to check if an editable region has content.

<r:page:unless_has_content_for /> is the equivalent of “if_doesnt_have_content_for”.

NOTE: You can use this tag to wrap anything in the <r:page /> context. This may prove helpful when pulling content from other pages via <r:page:content name="region-name" />.

Attribute Options

  • region="region-name" - The name of the editable region you want to check for content.
  • always_show_in_edit_mode - Boolean. Should the stuff between these tags show in edit mode? Default value: false.

Example

A good example for this tag is to check if there’s content in a sidebar on a page. If there’s not, don’t output the markup for the sidebar and make your main content area go full width (provided the CSS allows it).

<r:page:if_has_content_for region="wvu-sidebar" always_show_in_edit_mode="true">
  <aside class="sidebar">
    <r:editable_region name="wvu-sidebar" />
  </aside>
</r:page:if_has_content_for>

Another example is for student profiles. A student always has a major; however, a student doesn’t always have a minor. Here’s how to show a minor if they have one:

<r:page:if_has_content_for region="wvu-profile__minor" always_show_in_edit_mode="true">
  <p>
    <strong>Minor: </strong> <r:editable_region name="wvu-profile__minor" type="simple">
      Enter the person's minor. If they don't have one, delete this text and it won't show up in production.
    </r:editable_region>
  </p>
</r:page:if_has_content_for>

And here’s how to only show the minor on the profile index page if they have one:

<r:children:each> <!-- Heads up! You may already have this r:children:each tag in your template. -->
  <r:page:if_has_content_for region="wvu-profile__minor">
    <p>
      <strong>Minor: </strong><r:page:content name="wvu-profile__minor" />
    </p>
  </r:page:if_has_content_for>
</r:children:each>

Last updated on February 12, 2016.

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.