Advertising sustains the DA. Ads are hidden for members. Join today

On this page

Introduction

Last updated on
21 September 2023

Introduction

Atoms is meant to give developers an easy and quick way to add small pieces of content to a site that an administrator can then freely change as they see fit. Of course there are many options for content already like nodes and other entities to fill out a page, but these are usually overkill when just talking about a text in a custom form or similar.

This is what Atoms is for. Very small pieces of content in places where it's usually quite bothersome to embed any other type of content entity.

Usage

For most use cases using a Atoms is as easy as calling the atom() function whenever you need it.

$build = atom('example-machine-name');

This returns a render array with all the necessary cacheability information and context menus for the Atom in question. There are also other variants for more specialized uses like atom_lazy() which works like atom() but as a lazy builder where performance might be an issue. Last we have atom_str() which just delivers a rendered string, but cacheability is lost and must be taken care of manually.

There are also Twig functions with the same names...

<p>{{ atom('example-machine-name') }}</p>

Help improve this page

Page status: No known problems

You can: