Building a site
Editable content
Everything an editor changes on a page is a block: a piece of text, formatted text, an image or a link. You write a block into a template with the <x-block> component, and its slot is the content the page shows until someone edits it.
<x-block name="title" tag="h1">Welcome</x-block>
When an editor signs in, the block becomes editable on the page. Saving makes a draft that only editors see, and Publish makes it live.
Editable blocks
Lapis has four block types. The type attribute chooses one, and plain text is the default:
<x-block name="title" tag="h1">Default title</x-block> <x-block name="lead" tag="p" placeholder="An opening sentence…" /> <x-block name="intro" tag="p" multiline>Plain text on several lines</x-block> <x-block name="body" type="richtext"><p>Formatted text</p></x-block> <x-block name="hero" type="image" class="hero" :src="$cms->asset('images/hero.jpg')" alt="…" /> <x-block name="cta" type="link" class="button" href="/contact">Write to us</x-block> <x-block name="footer_note" global>© Lapis</x-block> <!-- the same on every page -->
A block's content is stored per page. With the global attribute, one block is shared by the whole site, which suits a footer or an address. placeholder sets the hint shown to editors while a text block is empty, and an image block without a src renders nothing for visitors and a clickable placeholder for editors. Every other attribute (class, id, style and the rest) goes on the output element.
Rich text is sanitized on the server with an allow-list (Symfony's HTML sanitizer), so only safe formatting reaches the page. Images are covered in Images and media.
Blocks in loops
In a :foreach loop, give the default content with the :default attribute instead of the slot, and give every block a name of its own:
<li :foreach="$items as $n => $item"> <x-block :name="'item_' . $n . '_title'" tag="h3" :default="$item['title']" /> </li>
When editors should add and remove the items themselves, use a repeatable list instead.
Repeatable lists
A repeatable list is a list that editors can extend on the page: they can add, delete, reorder and duplicate its items. You write it with <x-repeat>, and the blocks inside it make up one item:
<?php // pages/prices.php $prices = [ ['title' => 'Single session', 'price' => '€40'], ['title' => 'Pass (5 sessions)', 'price' => '€180'], ]; $colors = fn (array $data, int $i) => ['style' => '--c:' . ($data['color'] ?? '#ccc')]; // optional ?> <x-repeat name="prices" tag="ul" item-tag="li" item-class="price" :items="$prices" :item-attributes="$colors"> <x-block name="title" tag="h3">New item</x-block> <x-block name="price" tag="p">€0</x-block> </x-repeat>
The :items are the default items until someone edits the list. Each inner <x-block> shows the item's value with the same key, and a new item shows the blocks' own slots. Inside an item, $cms->item('key') returns the item's other data, and the :item-attributes closure gives the attributes of each item. With the global attribute, the whole list is shared across every page.
The order of the items is a block itself, with drafts, publishing and history like any other. The fields are blocks named after the item, such as prices.{id}.title.
Publishing, history, preview
Changes stay drafts until an editor publishes them. The Drafts panel groups them by page, and you may publish or discard them page by page, or all at once.
Scheduling
With "Schedule…", a page's drafts go live at a given time. When cron runs schedule:run, it checks every minute. Without cron, the first visitor's request after that time runs it, before the page cache.
History
Every publish keeps a revision. For a text block, open the "History" button while editing it. For images and links, the button is "Earlier versions". Restoring an old version makes a draft, so you can look at it before publishing.
Preview links
The Page panel makes a preview link: a signed URL, valid for 3 days. It shows the page with its drafts to anyone who has the link, without the editor and with noindex, so you can send it to someone who does not sign in.