Demo: Diese Website ist eine Demo für fluid – keine offizielle Website von REDAXO. Operated by KLXM Crossmedia

REDAXO 6

Modules and templates as classes

No more PHP code in the database: modules and templates live in the project, versioned like any other code.

In development: REDAXO 6 is being built 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.

A module extends Module and carries the attribute #[AsModule]. Its fields are properties with field types as attributes – from these REDAXO builds the backend form, stores the values as JSON in the slice and fills the properties for the output. REDAXO finds the classes on its own.

A module

Text, textarea, an image from the media pool and a link to an article.

src/Module/TeaserModule.php PHP
<?php

namespace Project\Module;

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\MediaPicker;
use Redaxo\Core\Form\Field\Text;
use Redaxo\Core\Form\Field\Textarea;
use Redaxo\Core\MediaPool\Media;

use function Redaxo\Core\View\escape;

#[AsModule('teaser', 'Teaser')]
final class TeaserModule extends Module
{
    #[Text('Überschrift', required: true, maxLength: 120)]
    public string $headline = '';

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

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

    #[ArticlePicker('Weiterlesen auf')]
    public ?Article $link = null;

    public function output(): string
    {
        $html = '<article class="teaser">';
        if ($this->image) {
            $html .= '<img src="' . escape($this->image->getUrl()) . '" alt="">';
        }
        $html .= '<h2>' . escape($this->headline) . '</h2>';
        $html .= '<p>' . nl2br(escape($this->text)) . '</p>';
        if ($this->link) {
            $html .= '<a href="' . escape($this->link->getUrl()) . '">Weiterlesen</a>';
        }

        return $html . '</article>';
    }
}

More field types: Number, Email, Url, Checkbox, Choice, DatePicker, Collection (repeater group) …

Instead of MBlock

Repeating groups with Collection

A core field for lists of entries: every entry is an object of a small class with its own fields.

src/Module/SliderModule.php PHP
<?php

namespace Project\Module;

use Redaxo\Core\Content\AsModule;
use Redaxo\Core\Content\Module;
use Redaxo\Core\Form\Field\Collection;
use Redaxo\Core\Form\Field\Text;

use function Redaxo\Core\View\escape;

#[AsModule('slider', 'Slider')]
final class SliderModule extends Module
{
    #[Text('Überschrift')]
    public string $headline = '';

    /** @var list<Slide> */
    #[Collection('Slides', item: Slide::class, min: 1, max: 8)]
    public array $slides = [];

    public function output(): string
    {
        $html = '<div class="slider">';
        foreach ($this->slides as $slide) {
            $html .= '<figure>'
                . ($slide->image ? '<img src="' . escape($slide->image->getUrl()) . '" alt="">' : '')
                . '<figcaption>' . escape($slide->title) . '</figcaption></figure>';
        }

        return $html . '</div>';
    }
}
src/Module/Slide.php PHP
<?php

namespace Project\Module;

use Redaxo\Core\Content\Article;
use Redaxo\Core\Form\Field\ArticlePicker;
use Redaxo\Core\Form\Field\MediaPicker;
use Redaxo\Core\Form\Field\Text;
use Redaxo\Core\MediaPool\Media;

/** Ein Eintrag der Wiederholgruppe – eine kleine Klasse mit eigenen Feldern */
final class Slide
{
    #[Text('Titel', required: true, maxLength: 80)]
    public string $title = '';

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

    #[ArticlePicker('Link (optional)')]
    public ?Article $link = null;
}

Stored as a list of values per field key in the data column of the slice.

What Collection offers over MBlock

  • No extra AddOn: Collection is part of the core – fields, form, saving and validation like any other field.
  • Core fields per entry: text, choice, image, page, date … with required fields and lengths. If an entry is invalid, the form shows the error at that entry.
  • Values as objects: $this->slides is a list of Slide – with ?Media and ?Article instead of file names and IDs from a JSON.
  • References included: the core knows the images and pages in the entries – delete protection in the media pool and “used in” work.
  • Add, sort, remove with min and max, usable by keyboard. With fluid also in the sidebar on the website.

Moving from MBlock: MBlock stores the entries as JSON in a REX_VALUE. Collection stores a list of entries with values per field key in the data column of the slice – so the old data can be taken over with a small script: map the keys of the MBlock fields to the properties of the entry class.

A template with two content sections

The template defines which content sections exist and which modules are allowed in them. The markup lives in a view file next to it.

src/Template/PageTemplate.php PHP
<?php

namespace Project\Template;

use Override;
use Project\Module\TeaserModule;
use Redaxo\Core\Content\ArticleContent;
use Redaxo\Core\Content\AsTemplate;
use Redaxo\Core\Content\ContentSection;
use Redaxo\Core\Content\Template;
use Redaxo\Core\View\HasView;

#[AsTemplate('page', 'Seite')]
final class PageTemplate extends Template
{
    use HasView;

    #[Override]
    public function getContentSections(): array
    {
        return [new ContentSection(1, 'Inhalt'), new ContentSection(2, 'Seitenleiste')];
    }

    #[Override]
    public function isModuleAllowed(ContentSection $section, string $module): bool
    {
        // In der Seitenleiste nur Teaser
        return 2 !== $section->id || TeaserModule::class === $module;
    }

    #[Override]
    public function render(ArticleContent $content): string
    {
        return $this->renderView($content);   // PageTemplate.view.php daneben
    }
}
src/Template/PageTemplate.view.php PHP
<?php

use Redaxo\Core\Content\ArticleContent;

use function Redaxo\Core\View\escape;

return static function (ArticleContent $content): void { ?>
    <!DOCTYPE html>
    <html lang="de">
    <head>
        <meta charset="utf-8">
        <title><?= escape($content->article->name) ?></title>
    </head>
    <body>
        <main><?= $content->renderContent(1) ?></main>
        <aside><?= $content->renderContent(2) ?></aside>
    </body>
    </html>
<?php };

With fluid

Your own template with fluid’s elements

Two lines are enough: KitHead writes title, SEO tags, styles and scripts of the kit – once the page is done, so only for the elements it really uses.

src/Template/PageTemplate.view.php PHP
<?php

use Klxm\Fluid\KitHead;
use Redaxo\Core\Content\ArticleContent;

return static function (ArticleContent $content): void { ?>
    <!DOCTYPE html>
    <html lang="de" <?= KitHead::htmlAttributes() ?>>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <?= KitHead::render() ?>
    </head>
    <body>
        <main id="main"><?= $content->renderContent(1) ?></main>
        <aside><?= $content->renderContent(2) ?></aside>
    </body>
    </html>
<?php };

Without KitHead, editing on the website and ordinary modules still work.

Set the default template

The Project class is the entry point into your own project – for configuration, boot and your own tables.

src/Project.php PHP
<?php

namespace Project;

use Override;
use Project\Template\PageTemplate;
use Redaxo\Core\AbstractProject;
use Redaxo\Core\Content\Template;

final class Project extends AbstractProject
{
    #[Override]
    public function boot(): void
    {
        Template::setDefault(PageTemplate::class);   // Template für neue Artikel
    }
}

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.