Page Definitions
By default any page may contain any registered section. A Page Definition declares, in PHP, which sections a kind of page may contain, which it must contain, which can't move, and what a new page starts with. Inlay enforces it in the section picker, in the editor's controls, server-side on every action, and at publish.
Writing one
The landing starter kit's definition:
namespace App\Inlay;
use WeArePixel\Inlay\Attributes\PageDefinitionMeta;
use WeArePixel\Inlay\Pages\PageDefinition;
use WeArePixel\Inlay\Support\SectionHandle;
#[PageDefinitionMeta(handle: 'landing-page', label: 'Landing page', description: 'A campaign or product landing page that opens with a hero.')]
final class LandingPage extends PageDefinition
{
public function allowedSections(): array
{
return array_map(SectionHandle::make(...), [
'hero', 'logo-cloud', 'feature-grid', 'split-media', 'stats',
'testimonials', 'pricing', 'faq', 'cta-band', 'rich-text', 'content',
]);
}
public function requiredSections(): array
{
return [SectionHandle::make('hero')];
}
public function defaultSections(): array
{
return array_map(SectionHandle::make(...), ['hero', 'feature-grid', 'cta-band']);
}
}
Register it after the sections it references:
Inlay::pageDefinition(LandingPage::class);
Inlay::pageDefinitions([LandingPage::class, CollectionPage::class]);
References are validated at registration: an unregistered section, a duplicate definition handle, or a locked section that isn't also required all throw immediately.
Referencing sections
Each reference is either a class-based section's class (Hero::class) or a SectionHandle::make('hero') for a single-file section. Bare strings aren't accepted, so a typo fails loudly instead of doing nothing.
Metadata
#[PageDefinitionMeta] is optional and accepts handle, label, description and icon. Without it the handle and label come from the class name (CollectionPage becomes collection-page, "Collection Page").
Rules
- Allowed -
allowedSections()returningnull(the default) allows every section. A section listed as required, locked or default is always allowed too. - Required - at least one instance must exist before the page can be published. The editor won't delete the last one.
- Locked - every instance can be neither deleted nor reordered. A locked section must also be required. A duplicate of a locked section is locked too.
- Default - seeded, in order, when a page of this kind is created. Repeating a handle seeds two instances.
The built-in default definition allows every section and requires, locks and seeds nothing. Page creation shows a "Page type" choice only once more than one definition is registered. A page's type is fixed when it's created.
None of the editor's guardrails are the security boundary: adding, deleting, duplicating and reordering are each re-checked on the server.
Publishing
One validator, WeArePixel\Inlay\Pages\PageDefinitionValidator, drives both the editor's banner and the publish gate. It reports a section the definition doesn't allow, a missing required section, a definition that's no longer registered, and a section type that's no longer registered. Publishing throws PageDefinitionViolationException while any of these apply.
Already-published revisions are never invalidated. Tightening a definition blocks the next publish of a page that breaks it; what's live keeps rendering.
Restoring revisions
Restoring an older revision replaces the draft. If the restored content satisfies the page's current definition, the restore publishes too. If it doesn't, it stays a draft until it's corrected.