REDAXO 6

# Native modules on the website

Ordinary REDAXO modules – without fluid fields – can be maintained on the website with fluid: in the same sidebar as the blocks.

 
 
 

 

**In development:** REDAXO 6 is being developed in the 6.x branch of redaxo/core. The examples reflect the state of November 2026 – names and details may still change before the release.

“Native modules” here are ordinary REDAXO 6 modules: a class with `#[AsModule]`, fields as attributes and `output()` – nothing from fluid. They sit next to the fluid blocks on the same page and can be maintained on the website just like the blocks.

### How fluid handles them

- In edit mode a module gets the same bar as the blocks: edit, move, online/offline, copy, cut, duplicate, delete and the round “+” to insert after it.
- The sidebar shows its fields in fluid’s form – text, text area, email, web address, number, yes/no, choice, date, time, image from the media pool and page link.
- “Übernehmen” checks like the backend (required fields, length, valid values, the module’s `validate()`), saves to the draft and refreshes the output on the page. Visitors see it after “Veröffentlichen”.
- If a module builds its form with its own `input()` or uses other field types (e.g. repeaters, multiple choice), the sidebar shows the core’s form.
- The “fluid” template allows ordinary modules next to the kit’s blocks. They can be added on the website too: the library lists them under “REDAXO-Module” – their form comes first, after “Übernehmen” the module is on the page. Modules with their own `input()` show the core’s form in the sidebar.

**Try it:** When logged in, tap “Bearbeiten” at the top and hover over the two examples below. This is not available in the demo access without login.

 
 

## A native module to try out

fluid does not know this module – it is an ordinary module class. In edit mode, “Bearbeiten” in the bar opens its fields in the sidebar.

**Module with its own form**

Its input() builds the form itself – so the sidebar shows the core’s form.

 

## The example module

Fields as properties with the core’s field attributes, the output in output(). That is all fluid needs.

 
 
 
src/Module/HinweisModule.php PHP
 

```
<?php

namespace Project\Module;

use DateTimeImmutable;
use Redaxo\Core\Content\Article;
use Redaxo\Core\Content\AsModule;
use Redaxo\Core\Content\Module;
use Redaxo\Core\Form\Field\ArticlePicker;
use Redaxo\Core\Form\Field\Checkbox;
use Redaxo\Core\Form\Field\Choice;
use Redaxo\Core\Form\Field\DatePicker;
use Redaxo\Core\Form\Field\MediaPicker;
use Redaxo\Core\Form\Field\Text;
use Redaxo\Core\Form\Field\Textarea;
use Redaxo\Core\Http\Response;
use Redaxo\Core\MediaPool\Media;

use function Redaxo\Core\View\escape;

/**
 * Example: an ordinary REDAXO 6 module (no fluid block). Fields are properties with the core field
 * attributes, output() writes the output. fluid shows the fields on the website in its own sidebar.
 */
#[AsModule('hinweis', 'Hinweis (Beispiel)')]
final class HinweisModule extends Module
{
    #[Text(
        'Überschrift',
        required: true,
        maxLength: 120,
    )]
    public string $headline = '';

    #[Textarea(
        'Text',
        rows: 4,
    )]
    public string $text = '';

    #[Choice(
        'Art',

        choices: ['info' => 'Information', 'warn' => 'Warnung', 'ok' => 'Erledigt'],
    )]
    public string $kind = 'info';

    #[Checkbox('Hervorheben')]
    public bool $strong = false;

    #[DatePicker('Gültig bis')]
    public ?DateTimeImmutable $until = null;

    #[MediaPicker(
        'Bild',
        types: ['jpg', 'jpeg', 'png', 'webp'],
    )]
    public ?Media $image = null;

    #[ArticlePicker('Mehr dazu')]
    public ?Article $link = null;

    public function output(): string
    {
        // No style attributes (Content Security Policy of the backend): classes and a <style nonce> once per page
        $html = self::css() . '<div class="wrap"><aside class="hinweis hinweis--' . escape($this->kind) . ($this->strong ? ' is-strong' : '') . '">';
        $html .= '<h2>' . escape($this->headline) . '</h2>';
        if ('' !== $this->text) {
            $html .= '<p>' . nl2br(escape($this->text)) . '</p>';
        }
        if ($this->until) {
            $html .= '<p class="hinweis__until">Gültig bis ' . $this->until->format('d.m.Y') . '</p>';
        }
        if ($this->image) {
            $html .= '<img class="hinweis__image" src="' . escape($this->image->getUrl()) . '" alt="">';
        }
        if ($this->link) {
            $html .= '<p><a href="' . escape($this->link->getUrl()) . '">' . escape($this->link->name) . ' →</a></p>';
        }

        return $html . '</aside></div>';
    }

    /** Styles of the module – once per page, with the response nonce (allowed under the CSP) */
    private static function css(): string
    {
        static $done = false;
        if ($done) {
            return '';
        }
        $done = true;

        return '<style nonce="' . escape(Response::getNonce()) . '">'
            . '.hinweis{--c:var(--f-a,#2563eb);margin-block:2rem;padding:1.5rem 2rem;border-left:6px solid var(--c);border-radius:var(--f-radius,6px);background:var(--f-surface,#f5f6f8)}'
            . '.hinweis--warn{--c:#dc2626}.hinweis--ok{--c:#16a34a}.hinweis.is-strong{box-shadow:0 0 0 2px var(--c)}'
            . '.hinweis h2{margin:0 0 .5rem}.hinweis p{margin:.75rem 0 0}.hinweis h2+p{margin-top:0}.hinweis__until{font-size:.9em}'
            . '.hinweis__image{display:block;max-width:min(100%,24rem);margin-top:1rem;border-radius:var(--f-radius,6px)}'
            . '</style>';
    }
}
```

 
 
 

The complete examples are in examples/module of the fluid addon.

 
 

 

## Own form

With its own input() the module decides how its form is built – then fluid shows the core’s form.

 
 
 
src/Module/HinweisEigenesFormularModule.php PHP
 

```
public function input(Form $form): string
{
    // eigener Aufbau – fluid zeigt dafür das Formular des Cores in der Seitenleiste
    return '<p class="rex-field-note">Hinweis über den Feldern</p>' . $form->rest();
}
```

 
 
 
 
 

 

Going further with fluid

## From native module to fluid block

 

A native module works with fluid unchanged. If it should feel like fluid’s blocks, it takes three steps:

1. **Class:** extends `FluidBlock` instead of `Module`; the key starts with `fluid.`.
2. **Fields:** stay as they are – the core’s attributes including `Collection`. If you like, use the ones of the same name from `Klxm\Fluid\Field`: the same parameters, plus optional `width`, `variants` or `placeholder` for the sidebar. Fields only fluid has: `Link`, `RichText`, `Icon` and others.
3. **Output:** `output()` stays `output()`; `$this->edit('field')` makes a field editable right on the page.

**What you gain:** text right on the page, preview while typing, the block appears in the block library on the website, background and spacing per section, layout columns, copy and paste, handles – and the look comes from the kit, also when switching the design preset.

**Good to know:** the key changes, so existing slices of the native module do not become blocks by themselves. Both can coexist – new content with the block, old content stays until it is replaced.

 
 

 

## The same notice as a fluid block

One class: fields as attributes, output in output() – like the module, just with another base class.

 
 
 
src/Block/Hinweis.php PHP
 

```
<?php

namespace Project\Block;

use DateTimeImmutable;
use Klxm\Fluid\Field\AsFluidBlock;
use Klxm\Fluid\Field\Checkbox;
use Klxm\Fluid\Field\Choice;
use Klxm\Fluid\Field\DatePicker;
use Klxm\Fluid\Field\Link;
use Klxm\Fluid\Field\MediaPicker;
use Klxm\Fluid\Field\Text;
use Klxm\Fluid\Field\Textarea;
use Klxm\Fluid\InlineStyle;
use Klxm\FluidPlus\Kit\Native\FluidBlock;
use Override;
use Redaxo\Core\Content\AsModule;
use Redaxo\Core\MediaPool\Media;

use function Redaxo\Core\View\escape;

/**
 * The example module „Hinweis“ (examples/module/HinweisModule.php) as a fluid block. Compared to the module:
 *
 *  1. extends FluidBlock instead of Module, the key starts with „fluid.“, #[AsFluidBlock] for the block picker;
 *  2. the fields remain those of the core – here the fluid ones of the same name, which also know `width` (half width in the
 *     sidebar); plus Link, a field only fluid has;
 *  3. output() stays output(): `$this->edit('feld')` makes a field editable directly on the page.
 */
#[AsModule('fluid.hinweis', 'Hinweis')]
#[AsFluidBlock(icon: 'info', group: 'Inhalt', nestable: true, help: 'Kurzer Hinweis mit Art, Bild und Link.')]
final class Hinweis extends FluidBlock
{
    #[Text(
        'Überschrift',
        required: true,
        maxLength: 120,
    )]
    public string $headline = '';

    #[Textarea(
        'Text',
        rows: 4,
    )]
    public string $text = '';

    #[Choice(
        'Art',
        choices: ['info' => 'Information', 'warn' => 'Warnung', 'ok' => 'Erledigt'],
        width: 'half',
    )]
    public string $kind = 'info';

    #[Checkbox(
        'Hervorheben',
        width: 'half',
    )]
    public bool $strong = false;

    #[DatePicker(
        'Gültig bis',
        width: 'half',
    )]
    public ?DateTimeImmutable $until = null;

    #[Link(
        'Mehr dazu',
        width: 'half',
    )]
    public string $link = '';

    #[MediaPicker(
        'Bild',
        preview: true,
    )]
    public ?Media $image = null;

    #[Override]
    public function output(): string
    {
        $color = ['warn' => '#dc2626', 'ok' => '#16a34a'][$this->kind] ?? 'var(--f-a)';
        // no style attributes (CSP): InlineStyle assigns a class, the rule is in the <style nonce> of the page
        $style = 'padding:var(--f-s-l);border-left:6px solid ' . $color . ($this->strong ? ';box-shadow:0 0 0 2px ' . $color : '');
        $html = '<div class="wrap"><aside class="card ' . InlineStyle::class($style) . '">'
            . '<h2 class="h3"' . $this->edit('headline') . '>' . escape($this->headline) . '</h2>'
            . '<p' . $this->edit('text', 'lines') . '>' . nl2br(escape($this->text), false) . '</p>';
        if ($this->until) {
            $html .= '<p class="muted">Gültig bis ' . escape($this->until->format('d.m.Y')) . '</p>';
        }
        if ($this->image) {
            $html .= img($this->image->fileName, '24rem');
        }
        if ('' !== trim($this->link)) {
            $html .= '<p><a ' . fluid_link_attrs($this->link) . '>Mehr dazu →</a></p>';
        }

        return $html . '</aside></div>';
    }
}
```

 
 
 

More in the developer reference (docs/entwickler.md, “Ein eigener Block”) and on the page “Custom kit”.

 
 

## The same notice as a fluid block

Change this text right here on the page – as with every block, all fields are in the sidebar.

 

 
 
 

Try it

 

## This site is built with REDAXO 6 and fluid.

 

Sign in, tap “Edit” – and change every text, every image and the whole design right here.

 
 
[How editing works](https://fluid.klxm.de/en/fluid/editing/)[See the technology](https://fluid.klxm.de/en/redaxo-6/technology/)


---

Source: https://fluid.klxm.de/en/fluid/native-modules/
<style nonce="c30a26b16d13389cab0e1464797947ae">.fs-71b5bf8401{padding:var(--f-s-l) !important;border-left:6px solid #16a34a !important}.fs-455c15fee1{--ncss-grid-min:13rem !important}</style>