Admin

Create, edit, delete Page, Media, User with an interface built on top of EasyAdmin.

Install

composer require pushword/admin

That’s it! If you have a custom installation (not used the default installer), you may have a look inside vendor/pushword/admin/install.php.

Admin is now accessible via https://mydomain.tld/admin/.

Don’t forget to create an user with ROLE_SUPER_ADMIN to access to the just installed admin:

php bin/console pw:user:create

You may be intersted by the block editor.

Editing a page

The body is edited in Monaco, with a toolbar above it and a word/line count below. Formatting is a toggle: pressing a button a second time removes what it added, and with nothing selected it applies to the word under the cursor.

KeyWhat it does
Ctrl+B / Ctrl+Ibold, italic
Alt+Sstrikethrough
Ctrl+Shift+] / Ctrl+Shift+[move the heading level up and down
Alt+Ctick or untick a task item, making one if the line is not a task yet
Ctrl+Kwrap the selection in a link
Entercarry the list marker over, numbering the next ordered item; on an empty item, end the list
F1every command, by name

Pasting a URL onto selected text links that text instead of replacing it. The toolbar’s last two buttons open the editor fullscreen and the markdown cheatsheet.

The same editor, toolbar included, backs the markdown mode of admin-block-editor.

Saving is always something you ask for: Ctrl+S saves without leaving the form, and the Save and continue editing button shows the result. There is no timed autosave, on purpose — a page save is a publication (it rewrites the flat markdown, regenerates the Open Graph image, purges the static cache, and turns a half-typed slug into a redirect page), so nothing writes to the server until you say so.

What is automatic is the safety net. While you type, the form state is kept in your browser’s localStorage, and reopening the page offers it back:

You left unsaved changes here 7 minutes ago, kept in this browser. Restore them · Discard

It covers the crash, the closed tab and the expired session. Restore them puts back the fields you had changed (the markdown body included) and nothing else, without saving anything, so you still review before publishing; a field you never touched keeps whatever the page holds now, even if a colleague saved it meanwhile. Should that colleague have saved one of your fields, the offer says so before you take it:

You left unsaved changes here 7 minutes ago, kept in this browser. The page has been saved since, on fields you changed: restoring puts your version back over it.

The copy is only dropped once a save succeeds, or when you press Discard. It never leaves your browser, so it does not follow you to another machine, and it belongs to the account that typed it: it is not offered to anyone else signing in on that browser, and signing out takes it along. It is unrelated to the Draft toggle, which is a publication state stored in the database.

A site overriding @pwAdmin/page/edit.html.twig has to carry over the unsaved_changes_banner.html.twig include and the form’s data-pw-unsaved-key attribute, or the recovery has nowhere to render.

Customize the admin

Admin is built on top of EasyAdmin with one more feature: the ability to manage displayed form fields from the configuration (not yet for list fields and search fields).

You can also customize the admin menu to add, remove or reorder menu items.

So, in your configuration, your default configuration is:

pushword_admin:
    app_fallback_properties:
        - admin_page_form_fields
        - admin_user_form_fields
    admin_page_form_fields:
        -
            - Pushword\Admin\FormField\PageH1Field
            - Pushword\Admin\FormField\PageMainContentField
        -
            admin.page.state.label:
                - Pushword\Admin\FormField\PagePublishedAtField
                - Pushword\Admin\FormField\PageMetaRobotsField
            admin.page.permanlien.label:
                - Pushword\Admin\FormField\HostField
                - Pushword\Admin\FormField\PageSlugField
            admin.page.mainImage.label:
                - Pushword\Admin\FormField\PageMainImageField
            admin.page.parentPage.label:
                - Pushword\Admin\FormField\PageParentPageField
            admin.page.search.label:
                expand:              1
                fields:
                    - Pushword\Admin\FormField\PageTitleField
                    - Pushword\Admin\FormField\PageNameField
                    - Pushword\Admin\FormField\PageSearchExcreptField
                    - Pushword\Admin\FormField\WeightField
            admin.page.translations.label:
                - Pushword\Admin\FormField\PageLocaleField
                - Pushword\Admin\FormField\PageTranslationsField
            admin.page.customProperties.label:
                expand:              1
                fields:
                    - Pushword\Admin\FormField\CustomPropertiesField
            admin.page.og.label:
                expand:              1
                fields:
                    - Pushword\Admin\FormField\OgTitleField
                    - Pushword\Admin\FormField\OgDescriptionField
                    - Pushword\Admin\FormField\OgImageField
                    - Pushword\Admin\FormField\OgTwitterCardField
                    - Pushword\Admin\FormField\OgTwitterSiteField
                    - Pushword\Admin\FormField\OgTwitterCreatorField
    admin_user_form_fields:
        -
            - Pushword\Admin\FormField\UserEmailField
            - Pushword\Admin\FormField\UserUsernameField
            - Pushword\Admin\FormField\UserPasswordField
            - Pushword\Admin\FormField\CreatedAtField
        -
            admin.user.label.security:
                - Pushword\Admin\FormField\UserRolesField

You can directly edit this default list or customize them by editing this list on the fly with the pushword.admin.load_field event (see admin-block-editor extension for an example).

You can customize fields on app level, but when we create a new page, we don’t know yet in wich app we are, we will use first app configuration (or global).