diff --git a/code_samples/back_office/components/twig_components.yaml b/code_samples/back_office/components/twig_components.yaml new file mode 100644 index 0000000000..bfcfc70e1e --- /dev/null +++ b/code_samples/back_office/components/twig_components.yaml @@ -0,0 +1,41 @@ +ibexa_twig_components: + admin-ui-user-menu: + custom-html-component: + type: html + arguments: + content: 'Hello world!' + custom-template-component: + type: template + arguments: + template: '@ibexadesign/ui/component/user_thumbnail/user_thumbnail.html.twig' + parameters: + user_content: + name: "Thumbnail" + thumbnail: + resource: https://placecats.com/100/100 + custom-controller-component: + type: controller + arguments: + controller: '\App\Controller\MyController::requestAction' + parameters: + parameter1: 'custom' + parameter2: true + admin-ui-stylesheet-head: + custom-link-component: + type: stylesheet + arguments: + href: 'https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback' + rel: stylesheet + crossorigin: anonymous + integrity: sha384-LN/mLhO/GN6Ge8ZPvI7uRsZpiXmtSkep+aFlJcHa8by4TvA34o1am9sa88eUzKTD + type: text/css + admin-ui-script-head: + custom-script-component: + type: script + arguments: + src: 'https://doc.ibexa.co/en/latest/js/custom.js' + crossorigin: anonymous + defer: false + async: true + integrity: sha384-Ewi2bBDtPbbu4/+fs8sIbBJ3zVl0LDOSznfhFR/JBK+SzggdRdX8XQKauWmI9HH2 + type: text/javascript diff --git a/code_samples/back_office/content_type/config/custom_services.yaml b/code_samples/back_office/content_type/config/custom_services.yaml index ddf035c414..950a905d20 100644 --- a/code_samples/back_office/content_type/config/custom_services.yaml +++ b/code_samples/back_office/content_type/config/custom_services.yaml @@ -4,4 +4,4 @@ services: arguments: $template: '@@ibexadesign/content_type/edit/custom_tab.html.twig' tags: - - { name: ibexa.admin_ui.component, group: 'content-edit-sections' } + - { name: ibexa.twig.component, group: 'admin-ui-content-edit-sections' } diff --git a/code_samples/back_office/dashboard/article_tab/config/custom_services.yaml b/code_samples/back_office/dashboard/article_tab/config/custom_services.yaml index 96a6884ab9..fb629359bc 100644 --- a/code_samples/back_office/dashboard/article_tab/config/custom_services.yaml +++ b/code_samples/back_office/dashboard/article_tab/config/custom_services.yaml @@ -10,4 +10,4 @@ services: arguments: $groupIdentifier: 'custom_group' tags: - - { name: ibexa.admin_ui.component, group: 'dashboard-blocks' } + - { name: ibexa.twig.component, group: 'admin-ui-dashboard-blocks' } diff --git a/code_samples/back_office/search/config/append_to_services.yaml b/code_samples/back_office/search/config/append_to_services.yaml index d696ba4c7a..c7013c63a8 100644 --- a/code_samples/back_office/search/config/append_to_services.yaml +++ b/code_samples/back_office/search/config/append_to_services.yaml @@ -25,7 +25,7 @@ services: $template: '@@ibexadesign/ui/global_search_autocomplete_product_template.html.twig' $groupIdentifier: 'global-search-autocomplete-product' tags: - - { name: ibexa.admin_ui.component, group: global-search-autocomplete-templates } + - { name: ibexa.twig.component, group: global-search-autocomplete-templates } App\Search\SortingDefinition\Provider\SectionNameSortingDefinitionProvider: tags: diff --git a/code_samples/user_management/oauth_google/config/custom_services.yaml b/code_samples/user_management/oauth_google/config/custom_services.yaml index e4bceef1cf..5897e991bf 100644 --- a/code_samples/user_management/oauth_google/config/custom_services.yaml +++ b/code_samples/user_management/oauth_google/config/custom_services.yaml @@ -10,4 +10,4 @@ services: arguments: $template: '@@ibexadesign/account/login/oauth2_login.html.twig' tags: - - { name: ibexa.admin_ui.component, group: login-form-after } + - { name: ibexa.twig.component, group: admin-ui-login-form-after } diff --git a/docs/administration/back_office/back_office_elements/custom_components.md b/docs/administration/back_office/back_office_elements/custom_components.md index f191f0a6a9..6e975e0add 100644 --- a/docs/administration/back_office/back_office_elements/custom_components.md +++ b/docs/administration/back_office/back_office_elements/custom_components.md @@ -2,85 +2,118 @@ description: Back office components allow you to inject any custom widgets into selected places of the user interface. --- -# Custom components - -The back office has designated places where you can use your own components. - -Components enable you to inject widgets (for example, **My dashboard** blocks) and HTML code (for example, a tag for loading JS or CSS files). -A component is any class that implements the `Renderable` interface. -It must be tagged as a service in `config/services.yaml`: - -``` yaml -App\Component\MyNewComponent: - tags: - - { name: ibexa.admin_ui.component, group: content-edit-form-before } -``` - -`group` indicates where the widget is displayed. The available groups are: - -- [`stylesheet-head`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/ui/layout.html.twig#L101) -- [`script-head`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/ui/layout.html.twig#L102) -- [`stylesheet-body`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/ui/layout.html.twig#L210) -- [`script-body`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/ui/layout.html.twig#L211) -- [`content-edit-form-before`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/user/edit.html.twig#L37) -- [`content-edit-form-after`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/user/edit.html.twig#L47) -- [`content-create-form-before`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/user/create.html.twig#L37) -- [`content-create-form-after`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/user/create.html.twig#L45) -- [`dashboard-blocks`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/ui/dashboard/dashboard.html.twig#L30) -- [`dashboard-all-tab-groups`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/ui/dashboard/block/all.html.twig#L6) -- [`dashboard-my-tab-groups`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/ui/dashboard/block/me.html.twig#L6) -- [`content-type-tab-groups`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/content_type/index.html.twig#L37) -- `calendar-widget-before` -- [`login-form-before`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/account/login/index.html.twig#L7) -- [`login-form-after`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/account/login/index.html.twig#L70) -- [`global-search`](https://github.com/ibexa/admin-ui/blob/main/src/bundle/Resources/views/themes/admin/ui/layout.html.twig#L129) - -## Base component classes - -If you only need to inject a short element (for example, a Twig template or a CSS link) without writing a class, you can make use of the following base classes: - -- `TwigComponent` renders a Twig template. -- `LinkComponent` renders the HTML `` tag. -- `ScriptComponent` renders the HTML `