Editing in the admin

The admin panel: where editors work, what each tab of the edit panel does, and how templates connect the preview to its fields.

On this page

Signing in

The admin is the built-in phlat/admin addon, mounted at /admin. Anyone whose role has the admin.access permission can open it. Sign in at /admin/login, and create the first account from the terminal:

phlat user:create alex --role=admin

The mount slug and the admin's colour theme are set under its config entry:

{
    "addons": {
        "phlat/admin": { "mount": "admin", "theme": "phlatdark" }
    }
}

What editors see

The page tree lists every page, published or not. Opening a page shows the real site in a preview beside the edit panel, so what an editor sees is what visitors will get. Browsing inside the preview moves the tree to the page being shown, and each row of the tree has inline actions for that page.

The edit panel has four tabs:

Tab Holds
Data The fields the page's view lists, as form inputs
Files The page's files: upload, alt text, make private, delete
History Every saved revision of the page, with restore
Settings Published, access, hidden and locked. Needs the pages.publish permission

A view can limit the tabs its pages show with a tabs key in its _index.json:

// site/views/settings/_index.json
{
    "tabs": ["data", "files"]
}

The admin also has pages for users, collections, search and the system: installed addons, History sync and the registry.

Three overviews are for editors and need admin.access: /assets lists the site's files, /favicon checks the favicon set against what browsers and home screens ask for, and /fonts shows each font as a specimen. The pages stay public so their files keep serving.

With debug on, the Clockwork page lists the recorded requests, newest first. Filter them by URL, method and status class, and open one for its timeline, database queries, log, request, session, data and views. It needs admin.access, and without debug it is a 404.

Drafts and saving

Edits are autosaved as a draft, _draft.json in the page folder. Only editors see a draft, in the preview. Save writes the draft to the page and records it in History. A new page starts unpublished; publish it on the Settings tab. See Publishing and access.

Connecting templates to fields

Mark the element that shows a field with n:edit. In the preview, editors can then click it to jump to that field in the edit panel:

<h1 n:edit="$page->title">{$page->title}</h1>

<div n:edit="$page->body" class="prose">{$page->body|render}</div>

n:edit adds a data-edit-field attribute to the element and no wrapper. {edit $page->field}...{/edit} wraps its content in a <div> instead, for content with no single element of its own. Both mark only the preview, not the public page.

isAdminPreview() is true when the page is rendering inside the admin's preview for a signed-in editor, for markup only editors should see.

Customising

The admin is an addon like any other, so its templates can be overridden under site/views/@admin/. See Overrides. Field editors come from each field type's edit.latte. See Custom fields.