Skip to content

Box Partials

Box partials are standard October CMS partials. Once they have a Box config defined, they are available for use in the Boxes editor.

Accessing data

Every Box partial has access to a box variable. On that variable, you can access all data that was entered in the Boxes editor.

twig
<h1>{{ box.title }}</h1>

Accessing the render context

A Box is often part of a Page. Using the context variable, you can get information on where and how the Box is rendered on that page.

Loop

The context.loop property gives you access to Twig's original loop variable.

twig
{% if context.loop.first %}
    <h1>I am the first box on this page</p>
{% endif %}

Partial

The context.partial property gives you access to the Box partial and the Box config.

twig
Rendering {{ context.partial.path }}:
This partial is called {{ context.partial.config.name }}.

Check if the partial is rendered in the Boxes Editor

The context.isEditor property is true if the partial is rendered in the Boxes Editor in the backend.

twig
{% if context.isEditor %}
    Something special if rendered in the editor...
{% endif %}

Adding classes to the Box scaffolding

You can add custom classes to the Box scaffolding (.oc-box wrapper elements around each rendered partial) using the offline.boxes.extendBoxScaffoldingClasses event.

See Events for more information.