diff --git a/config/packages/sylius_twig_hooks.yaml b/config/packages/sylius_twig_hooks.yaml index 5a470853..1a6c8fc9 100644 --- a/config/packages/sylius_twig_hooks.yaml +++ b/config/packages/sylius_twig_hooks.yaml @@ -8,6 +8,11 @@ sylius_twig_hooks: page_body: template: 'book/show/content/page_body.html.twig' + 'sylius_admin.common.index.content.header.title_block': + title: + configuration: + icon: tabler:list-details + 'sylius_admin.book.index.content.header': description: template: 'book/index/content/header/description.html.twig' @@ -25,3 +30,10 @@ sylius_twig_hooks: props: form: '@=_context.form' initialFormData: '@=_context.resource' + + 'sylius_admin.speaker.index.content.header.title_block': + title: + template: '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/title.html.twig' + configuration: + icon: tabler:users + subheader: app.ui.managing_your_speakers diff --git a/docs/.gitbook/assets/icon_for_index_pages.png b/docs/.gitbook/assets/icon_for_index_pages.png new file mode 100644 index 00000000..a96890da Binary files /dev/null and b/docs/.gitbook/assets/icon_for_index_pages.png differ diff --git a/docs/.gitbook/assets/title_block_in_profiler.png b/docs/.gitbook/assets/title_block_in_profiler.png new file mode 100644 index 00000000..bf327b5e Binary files /dev/null and b/docs/.gitbook/assets/title_block_in_profiler.png differ diff --git a/docs/.gitbook/assets/title_with_icon.png b/docs/.gitbook/assets/title_with_icon.png new file mode 100644 index 00000000..cda79138 Binary files /dev/null and b/docs/.gitbook/assets/title_with_icon.png differ diff --git a/docs/.gitbook/assets/title_with_subheader.png b/docs/.gitbook/assets/title_with_subheader.png new file mode 100644 index 00000000..450d40db Binary files /dev/null and b/docs/.gitbook/assets/title_with_subheader.png differ diff --git a/docs/cookbook/admin_panel/index.md b/docs/cookbook/admin_panel/index.md index 373246d2..ee516e1d 100644 --- a/docs/cookbook/admin_panel/index.md +++ b/docs/cookbook/admin_panel/index.md @@ -4,3 +4,4 @@ * [Customizing the logo](logo.md) * [Customizing the menu](menu.md) * [Configuring the security access](security.md) +* [Customizing the page titles](page_titles.md) diff --git a/docs/cookbook/admin_panel/page_titles.md b/docs/cookbook/admin_panel/page_titles.md new file mode 100644 index 00000000..eec76622 --- /dev/null +++ b/docs/cookbook/admin_panel/page_titles.md @@ -0,0 +1,83 @@ +# Customizing the page titles + +## Adding an icon + +
+ +
Title with icon
+ +
+ +To add an icon to the page title, you need to use Twig hooks configuration. + +Search the "title_block" in the Symfony debug profiler at the Twig hooks section. + +
+ +
Title block in profiler
+ +
+ +Here's an example to define a "users" icon on a speaker list. + +```yaml +# config/packages/sylius_bootstrap_admin_ui.yaml +# ... +sylius_twig_hooks: + hooks: + # ... + 'sylius_admin.speaker.index.content.header.title_block': + title: + # We need to reuse the same template as 'sylius_admin.common.index.content.header.title_block' + template: '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/title.html.twig' + configuration: + icon: tabler:users # you can use any icon from Symfony UX icons. +``` + +You can also define a default icon for every "index" pages. + +
+ +
Icon for index pages
+ +
+ +```yaml +# config/packages/sylius_bootstrap_admin_ui.yaml +# ... +sylius_twig_hooks: + hooks: + # ... + 'sylius_admin.common.index.content.header.title_block': + title: + configuration: + icon: tabler:list-details +``` + +## Adding a subheader + +
+ +
Title with subheader
+ +
+ +To add a subheader to the page title, you need to use Twig hooks configuration. + +See the [previous section](#adding-an-icon) to see how to search for the title block. + +Here's an example to define a subheader on a speaker list. + +```yaml +# config/packages/sylius_bootstrap_admin_ui.yaml +# ... +sylius_twig_hooks: + hooks: + # ... + 'sylius_admin.speaker.index.content.header.title_block': + title: + # We need to reuse the same template as 'sylius_admin.common.index.content.header.title_block' + template: '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/title.html.twig' + configuration: + subheader: app.ui.managing_your_speakers # you also need add this key on your translations. +``` diff --git a/src/BootstrapAdminUi/templates/shared/crud/common/content/header/title_block/title.html.twig b/src/BootstrapAdminUi/templates/shared/crud/common/content/header/title_block/title.html.twig index 4ed13737..32e7d92a 100644 --- a/src/BootstrapAdminUi/templates/shared/crud/common/content/header/title_block/title.html.twig +++ b/src/BootstrapAdminUi/templates/shared/crud/common/content/header/title_block/title.html.twig @@ -7,10 +7,12 @@ {% set header = hookable_metadata.configuration.title %} {% endif %} +{% set icon = hookable_metadata.configuration.icon|default(null) %} +{% set subheader = hookable_metadata.configuration.subheader|default(null) %} {% set test_attribute = hookable_metadata.configuration.sylius_test_html_attribute is defined ? sylius_test_html_attribute(hookable_metadata.configuration.sylius_test_html_attribute) : null %}
- {{ header.h1(header|trans) }} + {{ header.h1(header|trans, icon, subheader|trans) }}
diff --git a/src/BootstrapAdminUi/templates/shared/helper/header.html.twig b/src/BootstrapAdminUi/templates/shared/helper/header.html.twig index 3671aee8..d4d9d384 100644 --- a/src/BootstrapAdminUi/templates/shared/helper/header.html.twig +++ b/src/BootstrapAdminUi/templates/shared/helper/header.html.twig @@ -1,7 +1,17 @@ {% macro default(level, header, icon, subheader) %} - - {{ header }} - +
+ {% if icon %} +
{{ ux_icon(icon, {'class': 'icon icon-md text-primary'}) }}
+ {% endif %} +
+ + {{ header }} + + {% if subheader %} +
{{ subheader }}
+ {% endif %} +
+
{% endmacro %} {% macro h1(header, icon, subheader) %} diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index 5dba7bda..67f50628 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -15,6 +15,7 @@ app: first_name: First name last_name: Last name library: Library + managing_your_speakers: Managing your speakers name: Name past_event: Past event show_talks: Show talks