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.
| Event | Arguments | Listener |
|---|---|---|
renick.content.registerBlocks | BlockManager | returns block configs, see Authoring blocks |
renick.content.registerIntegrations | none | returns Integration instances, see Writing your own integration |
renick.content.beforeRenderDocument | &$blocks, $context | edits the block tree, on every request |
renick.content.beforeRenderBlock | &$block, $preview | edits one block or returns replacement HTML |
renick.content.afterRenderBlock | &$html, $block, $preview | edits one block's HTML |
renick.content.afterRenderDocument | &$html, $context | edits the final HTML, on every request |
renick.content.formSubmit | $payload: form, fields, ip, site_id | receives a Form block submission after the spam and captcha checks, before the mail (not fired by the Submission form block) |
renick.content.api.resolveHostTypes | none | returns host model classes for REST and bundle commands |
renick.content.api.resolveContentFields | $host | returns 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.
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.
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.
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.
Event::listen('renick.content.api.resolveContentFields', function ($host) {
return $host instanceof \Acme\Blog\Models\Post ? 'content' : null;
});