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

← News

Columns? Solved. Pure REDAXO.

·

fluid-spalten-website

Two columns in REDAXO – up to now that mostly meant building brackets: a module “open column”, the contents, a module “close column”. Or one giant module with its own fields for every column. fluid solves it differently. With REDAXO itself.

The idea

An element Layout (columns) sets the split: ½ + ½, ⅔ + ⅓, three or four columns, plus alignment and gap. The contents are simply the slices right after it – each one only gets a column number. No wrapper, no end module, no nested data. The order is the core’s order.

What may go into a column

Every element with nestable: true – text, image, chart, quote, key figures or your own. And since fluid elements are REDAXO modules, that is no special case either: they are modules with a class, fields as attributes and output().

On the website

See columns, drag columns.

In edit mode every column shows its frame. The bar names the path – “Layout › Column 2/2 · Chart”. The column width is dragged right with the handle between them.

  • “+ Block in this column” in every column
  • Handle for the width
  • Move, copy, publish – per element
fluid-spalten-website
fluid-spalten-backend

In the backend

The same columns. The same slices.

In the backend the contents sit side by side in the layout – each with the core’s buttons: edit, delete, online, move. “+ Block in column 1” inserts right into the right column.

  • No backend of its own, no special form
  • Permissions like any module
  • The core’s versions and working version

Underneath

Pure REDAXO.

One click on “Tree” shows what is really stored: the layout, then perfectly ordinary slices – “Column 1/2 in layout ½ + ½”. A flat list, as REDAXO has always known it.

fluid-spalten-baum

Without fluid plus? Here’s how.

In the kits of fluid plus everything is ready: the element “Layout (columns)”, the CSS and elements that can go into columns. With fluid alone – without a kit, with your own templates – three files are enough: a layout element, an element that may go into columns and a few lines of CSS for the grid.

For developers

Three files, done.

Tested with fluid without fluid plus: layout element with BareKit, an element of your own with nestable and the grid as CSS.

src/Module/Spalten.php PHP
<?php

namespace Project\Module;

use Klxm\Fluid\BareKit;
use Klxm\Fluid\Kit;
use Klxm\Fluid\LayoutBlock;
use Redaxo\Core\Content\AsModule;

// Das Layout-Element: Felder (Aufteilung, Ausrichtung, Abstand …) und
// Ausgabe bringt LayoutBlock mit – nur das Kit fehlt.
#[AsModule('fluid.spalten', 'Spalten')]
final class Spalten extends LayoutBlock
{
    public static function kit(): Kit
    {
        return BareKit::instance();   // ohne Kit: Ihre Templates
    }
}
src/Module/Kachel.php PHP
<?php

namespace Project\Module;

use Klxm\Fluid\BareKit;
use Klxm\Fluid\BlockModule;
use Klxm\Fluid\Field\AsFluidBlock;
use Klxm\Fluid\Kit;
use Redaxo\Core\Content\AsModule;
use Redaxo\Core\Form\Field\Text;
use Redaxo\Core\Form\Field\Textarea;

use function Redaxo\Core\View\escape;

#[AsModule('fluid.kachel', 'Kachel')]
#[AsFluidBlock(icon: 'square', nestable: true)]   // darf in eine Spalte
final class Kachel extends BlockModule
{
    #[Text('Überschrift', required: true)]
    public string $title = '';

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

    public static function kit(): Kit
    {
        return BareKit::instance();
    }

    public function output(): string
    {
        return '<div class="kachel"><h3' . $this->edit('title') . '>' . escape($this->title) . '</h3>'
            . '<p' . $this->edit('text', 'lines') . '>' . nl2br(escape($this->text), false) . '</p></div>';
    }
}
public/css/spalten.css CSS
/* Spalten ohne Kit – das Raster, das Layout::render() ausgibt */
.lay-grid { display: flex; flex-wrap: wrap; gap: 2rem; }
.lay-col { flex: 1 1 0; min-inline-size: min(100%, 18rem); display: grid; gap: 1.5rem; align-content: start; }
.lay-col--w2 { flex-grow: 2; }
.lay-col--w3 { flex-grow: 3; }
.lay-v-center { align-items: center; }
.lay-v-bottom { align-items: flex-end; }
.lay-gap-small { gap: 1rem; }
.lay-gap-large { gap: 3.5rem; }
.lay-rev { flex-wrap: wrap-reverse; }

After creating them: composer dump-autoload and php bin/console cache:clear. The CSS goes into your template’s stylesheet.

That’s it. The layout element brings fields, output and editing – on the website and in the backend. More examples with backgrounds, cards and four columns are on the page Sections & columns.

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.