numberninecms / cms

Core code of NumberNine CMS
https://numberninecms.com
MIT License
19 stars 0 forks source link

Editor extensions #9

Closed williarin closed 3 years ago

williarin commented 3 years ago

Extend the classic editor with new tabs or sidebar components which can embed a form.
This form will be transformed into custom fields.

Example that adds a tab and a sidebar card with two new embedded forms:

final class PhotoGalleryEditorExtension implements EditorExtensionInterface
{
    public function build(EditorExtensionBuilderInterface $builder): void
    {
        $builder
            ->add('gallery_info', PhotoGalleryType::class, [
                'icon' => 'mdi-folder-multiple-image',
                'label' => 'Gallery information'
            ])
            ->add('author_info', GalleryAuthorType::class, [
                'label' => 'Author details'
            ], EditorExtensionBuilderInterface::COMPONENT_TYPE_SIDEBAR)
        ;
    }
}

Then change the content type registration to link it:

$event->addContentType(
    new ContentType([
        // ...
        'editor_extension' => PhotoGalleryEditorExtension::class,
    ])
);