Skip to content
On this page

Events

PHP Events

The following events are available in PHP.

Box

offline.boxes.beforeBoxRender

Called before a Box model is rendered.

php
Event::listen(
    \OFFLINE\Boxes\Classes\Events::BEFORE_BOX_RENDER,
    function(\OFFLINE\Boxes\Models\Box $box, \OFFLINE\Boxes\Classes\Partial\RenderContext $context) {}
);

offline.boxes.afterBoxRender

Called after a Box model was rendered.

php
Event::listen(
    \OFFLINE\Boxes\Classes\Events::AFTER_BOX_RENDER,
    function(\OFFLINE\Boxes\Models\Box $box, \OFFLINE\Boxes\Classes\Partial\RenderContext $context, string &$contents) {}
);

Page

offline.boxes.beforePageRender

Called before a Page model is rendered.

The $nestedBoxes variable holds the effective Box structure that will be rendered. You can use this to add or remove Boxes from the page before it is rendered.

php
Event::listen(
    \OFFLINE\Boxes\Classes\Events::BEFORE_PAGE_RENDER,
    function(\OFFLINE\Boxes\Models\Page $page, \OFFLINE\Boxes\Classes\Partial\RenderContext $context, \October\Rain\Database\Collection $nestedBoxes) {}
);

offline.boxes.afterPageRender

Called after a Page model was rendered.

php
Event::listen(
    \OFFLINE\Boxes\Classes\Events::AFTER_PAGE_RENDER,
    function(\OFFLINE\Boxes\Models\Page $page, \OFFLINE\Boxes\Classes\Partial\RenderContext $context, \October\Rain\Database\Collection $nestedBoxes, string &$contents) {}
);

Editor

offline.boxes.editorRender

Called when the Boxes Editor is rendered.

php
Event::listen(
    \OFFLINE\Boxes\Classes\Events::EDITOR_RENDER,
    function(\OFFLINE\Boxes\Components\BoxesPageEditor $editor) {}
);

JS Events

The following events are available in JS.

Editor

offline.boxes.editorRefreshed (JS)

Called, when the preview of the Boxes Editor was refreshed.

js
window.document.addEventListener('offline.boxes.editorRefreshed', function (e) {
    console.log('The editor was refreshed');
});