MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

SectionFields

MMO\editor\cms · 1 symbol · generated 27 Oct 2026

class

SectionFields

SectionFields.php:23

What a section's template prints its fields with ($_VARS['f'] in sections/{type}.phtml): every value is made safe for where it goes, so a template never escapes anything itself.

class MMO\editor\cms\SectionFields
Namespace
MMO\editor\cms
- `text($path)` escaped text; `html($path)` the rich text, sanitized again; `url($path)` a safe address; `image($path)` an `<img>`; `get($path)`/`has($path)` the raw value, to test it; - `each($path)` the items of a list, each a SectionFields of its own (`$item->text('title')`); - `root()` the attributes of the section's outer element: its anchor, and in the backoffice `data-section`; - `edit($path)` nothing on the public page; at the expert level the attributes making the field editable in place (`mmo-editor` and `data-path`), for [`PageRenderer::EDIT`](https://mmoframework.fr/en/documentation/mmo.editor/php/cms/PageRenderer.md#pagerenderer-edit). A path goes into objects with `.`: `cta.label`.
<section class="hero"<?= $f->root() ?>> <h1<?= $f->edit('title') ?>><?= $f->html('title') ?></h1> <a class="button" href="<?= $f->url('cta.url') ?>"><?= $f->text('cta.label') ?></a> </section>

Properties6

data

readonly
protected readonly array $data
Type
array

id

readonly
protected readonly ?string $id
Type
null | string

mode

readonly
protected readonly string $mode
Type
string

path

readonly
protected readonly string $path
Type
string

sanitizer

readonly
protected readonly ?MMO\editor\cms\Sanitizer $sanitizer
Type
null | Sanitizer

schema

readonly
protected readonly array $schema
Type
array

Methods13

edit($path)

SectionFields.php:131
function edit(string $path): string
$pathstring
returnsstringthe attributes making the field at $path editable in place: only at the expert level (PageRenderer::EDIT), nothing elsewhere -- mmo-editor="inline" for a field of one line, mmo-editor for rich text, data-path for any field

get($path, $default)

SectionFields.php:40
function get(string $path, mixed $default = null): mixed
$pathstring
$default = nullmixed
returnsmixedthe value at $path, $default when there is none

has($path)

SectionFields.php:50
function has(string $path): bool
$pathstring
returnsboolwhether $path holds something to show: not null, not an empty string, list or html

html($path)

SectionFields.php:69
function html(string $path): string
$pathstring
returnsstringthe rich text at $path, sanitized again (what a client sent is, when saved: what the application wrote itself may not be); a plain text field is escaped

image($path, $attributes)

SectionFields.php:89
function image(string $path, array $attributes = []): string
$pathstring
$attributes = []array
returnsstringthe <img> of the image at $path ({src, alt}), empty when it has no address

root($class)

SectionFields.php:114
function root(string $class = ''): string
$class = ''stringthe section's own classes
returnsstringthe attributes of the section's outer element: its id (the anchor its anchor field names), and out of the public page, data-section and data-type, which the backoffice finds it by

text($path, $default)

SectionFields.php:57
function text(string $path, string $default = ''): string
$pathstring
$default = ''string
returnsstringthe text at $path, escaped (html tags of a rich field are taken off)

url($path, $default)

SectionFields.php:78
function url(string $path, string $default = '#'): string
$pathstring
$default = '#'string
returnsstringthe address at $path, escaped for an attribute -- # when there is none, or it is not safe

__construct($data, $schema, $mode, $path, $id, $sanitizer)

SectionFields.php:30
function __construct( array $data, array $schema, string $mode, string $path, ?string $id = null, ?MMO\editor\cms\Sanitizer $sanitizer = new MMO\editor\cms\Sanitizer() )
$dataarray
$schemaarray
$modestring
$pathstringwhere $data is in the page, for data-path (sections.s1a2b3c4.data)
$id = nullnull | stringthe section's id, null for an item of a list
$sanitizer = new MMO\editor\cms\Sanitizer()null | Sanitizer