content_for

Table of contents

Content renderer for objects inside the Plate Nested Layout Structure: PostSectionRowColumn and Content Element. This not only renders the content, but also makes sure the content is editable for the user in the site’s edit mode, and adds HTML attributes for positioning so the content shows in the right place.

{% content_for post %}
  {% render_content %}
{% endcontent_for %}
Input
<div data-id="post_6734" class="plate--page-content-wrapper">
  <!-- Content for post -->
</div>
Output

You can add custom HTML attributes to extend the HTML container. If you add disable_handles: true, the content won’t show editing handles in edit mode, so the user is kept from editing the content.

{% content_for post, class: "test-class", data_test_data: "data-test-value", disable_handles: true %}
  {% render_content %}
{% endcontent_for %}
Input
<div data-id="post_6734" class="plate--page-content-wrapper test-class" data-test-data="data-test-value"> <!-- Handles disabled -->
  <!-- Content for post -->
</div>
Output

You can also add custom HTML attributes to the render_content tag inside the content_for block. This generates a div within the outer container, containing the content. This especially comes in handy for sections (which usually are full page width), that have a container div inside (that conforms to the Plate responsive grid system).

{% content_for section %}
  {% render_content class: "test-class" %}
{% endcontent_for %}
Input
<div data-id="section_44341" class="plate--section"> <!-- fullwidth -->
  <div class="plate--container test-class"> <!-- grid -->
    <!-- Content -->
  </div>
</div>
Output

Need help?

Do you have any question which is not answered in this knowledge base? Contact us. We are here to help you.