Skip to content

Events ​

Listen with Event::listen() in your Plugin::boot(). Only registerIntegrations needs register(), because Renick.Content builds the integration registry in its own boot(). Renderer listeners that throw are logged and skipped.

EventArgumentsListener
renick.content.registerBlocksBlockManagerreturns block configs, see Authoring blocks
renick.content.registerIntegrationsnonereturns Integration instances, see Writing your own integration
renick.content.beforeRenderDocument&$blocks, $contextedits the block tree, on every request
renick.content.beforeRenderBlock&$block, $previewedits one block or returns replacement HTML
renick.content.afterRenderBlock&$html, $block, $previewedits one block's HTML
renick.content.afterRenderDocument&$html, $contextedits the final HTML, on every request
renick.content.formSubmit$payload: form, fields, ip, site_idreceives a Form block submission after the spam and captcha checks, before the mail (not fired by the Submission form block)
renick.content.api.resolveHostTypesnonereturns host model classes for REST and bundle commands
renick.content.api.resolveContentFields$hostreturns the host's content field names for REST

Media and AI events are covered in the PHP API.

renick.content.beforeRenderBlock ​

Fired halting before a block's partial and children render. The first listener that returns a string replaces the block's output. Return null to keep rendering with your changes to $block. $preview is ['editor' => true] in the editor preview and [] on the frontend.

Frontend block HTML is cached, so both per-block events fire only when a block actually renders. Per-request logic belongs in afterRenderDocument.

php
Event::listen('renick.content.beforeRenderBlock', function (array &$block, array $preview) {
    if (($block['type'] ?? '') === 'placeholder') {
        return '<div id="my-widget"></div>';
    }
    return null;
});

renick.content.afterRenderDocument ​

Fired after the whole document rendered, even on a cache hit. Escape user-supplied or external values with e(): the HTML ships as-is.

php
Event::listen('renick.content.afterRenderDocument', function (string &$html, array $context) {
    $html = str_replace('{{year}}', date('Y'), $html);
});

renick.content.api.resolveHostTypes ​

The REST API and the renick:content:import-bundle / export-bundle commands only resolve Tailor EntryRecord subclasses, the host_types in config/api.php and the classes returned here. Only October\Rain\Database\Model subclasses count. Anything else is a 404.

php
Event::listen('renick.content.api.resolveHostTypes', fn () => [\Acme\Blog\Models\Post::class]);

renick.content.api.resolveContentFields ​

Decides whether the REST request's field is a content document field. Built in: document on Shared Content and contenteditor fields of Tailor entries. Any other field is a 422.

php
Event::listen('renick.content.api.resolveContentFields', function ($host) {
    return $host instanceof \Acme\Blog\Models\Post ? 'content' : null;
});