diff --git a/config/packages/sylius_twig_hooks.yaml b/config/packages/sylius_twig_hooks.yaml index 5481c592..3ccd786a 100644 --- a/config/packages/sylius_twig_hooks.yaml +++ b/config/packages/sylius_twig_hooks.yaml @@ -41,5 +41,6 @@ sylius_twig_hooks: title: template: '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/title.html.twig' configuration: + title: app.ui.browsing_speakers icon: tabler:users subheader: app.ui.managing_your_speakers diff --git a/docs/.gitbook/assets/browsing_speakers.png b/docs/.gitbook/assets/browsing_speakers.png new file mode 100644 index 00000000..db304cf4 Binary files /dev/null and b/docs/.gitbook/assets/browsing_speakers.png differ diff --git a/docs/.gitbook/assets/managing_speakers_subheader.png b/docs/.gitbook/assets/managing_speakers_subheader.png new file mode 100644 index 00000000..5eac4e94 Binary files /dev/null and b/docs/.gitbook/assets/managing_speakers_subheader.png differ diff --git a/docs/.gitbook/assets/speakers_icon.png b/docs/.gitbook/assets/speakers_icon.png new file mode 100644 index 00000000..99c8deeb Binary files /dev/null and b/docs/.gitbook/assets/speakers_icon.png differ diff --git a/docs/cookbook/admin_panel/page_titles.md b/docs/cookbook/admin_panel/page_titles.md index eec76622..c9e9faf3 100644 --- a/docs/cookbook/admin_panel/page_titles.md +++ b/docs/cookbook/admin_panel/page_titles.md @@ -1,5 +1,40 @@ # Customizing the page titles +## Changing the default title for a specific page + +
+ +
Title changed to Browsing speakers
+ +
+ +By default, each page has a default title based on both page location and resource name. +If you're not happy with the preset title for a specific page and would like to customize it, +you can easily change it using Twig Hooks. + +Search for "title_block" in the call graph of the Symfony debug profiler in the `Twig Hooks` section. + +
+ +
Title block in profiler
+ +
+ +We're going to reuse this hook and its template in our config file and add a `header` key: + +```yaml +# config/packages/sylius_bootstrap_admin_ui.yaml +# ... +sylius_twig_hooks: + hooks: + # ... + 'sylius_admin.speaker.index.content.header.title_block': + title: + template: '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/title.html.twig' + configuration: + title: app.ui.browsing_speakers # here is our title override +``` + ## Adding an icon
@@ -10,7 +45,8 @@ 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. +Search for "title_block" in the call graph of the Symfony debug profiler in the `Twig Hooks` section. +We're going to reuse this hook and its template in our config file.
@@ -79,5 +115,5 @@ sylius_twig_hooks: # 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. + subheader: app.ui.managing_your_speakers # you also need to add this key to your translations ``` diff --git a/src/BootstrapAdminUi/templates/shared/helper/header.html.twig b/src/BootstrapAdminUi/templates/shared/helper/header.html.twig index d4d9d384..4f322786 100644 --- a/src/BootstrapAdminUi/templates/shared/helper/header.html.twig +++ b/src/BootstrapAdminUi/templates/shared/helper/header.html.twig @@ -1,14 +1,14 @@ {% macro default(level, header, icon, subheader) %}
{% if icon %} -
{{ ux_icon(icon, {'class': 'icon icon-md text-primary'}) }}
+
{{ ux_icon(icon, {'class': 'icon icon-md text-primary'}) }}
{% endif %}
- + {{ header }} {% if subheader %} -
{{ subheader }}
+
{{ subheader }}
{% endif %}
diff --git a/tests/Functional/BookTest.php b/tests/Functional/BookTest.php index 1e3a990f..1cca2614 100644 --- a/tests/Functional/BookTest.php +++ b/tests/Functional/BookTest.php @@ -46,7 +46,7 @@ public function testShowingBook(): void self::assertResponseIsSuccessful(); // Validate Header - self::assertSelectorTextContains('h1.page-title', 'Shinning'); + self::assertSelectorTextContains('[data-test-page-title]', 'Shinning'); // Validate page body self::assertSelectorTextContains('[data-test-author-name]', 'Stephen King'); @@ -71,7 +71,7 @@ public function testBrowsingBooks(): void self::assertResponseIsSuccessful(); // Validate Header - self::assertSelectorTextContains('h1.page-title', 'Books'); + self::assertSelectorTextContains('[data-test-page-title]', 'Books'); self::assertSelectorExists('a:contains("Create")'); // Validate Custom Twig Hooks diff --git a/tests/Functional/ConferenceTest.php b/tests/Functional/ConferenceTest.php index 56b4de2d..a8b5451c 100644 --- a/tests/Functional/ConferenceTest.php +++ b/tests/Functional/ConferenceTest.php @@ -52,7 +52,7 @@ public function testBrowsingConferences(): void self::assertResponseIsSuccessful(); // Validate Header - self::assertSelectorTextContains('h1.page-title', 'Conferences'); + self::assertSelectorTextContains('[data-test-page-title]', 'Conferences'); self::assertSelectorExists('a:contains("Create")'); // Validate Table header diff --git a/tests/Functional/DashboardTest.php b/tests/Functional/DashboardTest.php index f4e1d6d4..374d21f9 100644 --- a/tests/Functional/DashboardTest.php +++ b/tests/Functional/DashboardTest.php @@ -35,6 +35,6 @@ public function testDashboard(): void self::assertResponseIsSuccessful(); - self::assertSelectorTextContains('h1.page-title', 'Dashboard'); + self::assertSelectorTextContains('[data-test-page-title]', 'Dashboard'); } } diff --git a/tests/Functional/SpeakerTest.php b/tests/Functional/SpeakerTest.php index 6213ecb4..a3dbe15e 100644 --- a/tests/Functional/SpeakerTest.php +++ b/tests/Functional/SpeakerTest.php @@ -50,7 +50,9 @@ public function testBrowsingSpeakers(): void self::assertResponseIsSuccessful(); // Validate Header - self::assertSelectorTextContains('h1.page-title', 'Speakers'); + self::assertSelectorTextContains('[data-test-page-title]', 'Browsing speakers'); + self::assertSelectorExists('[data-test-icon="tabler:users"]'); + self::assertSelectorTextContains('[data-test-subheader]', 'Managing your speakers'); self::assertSelectorExists('a:contains("Create")'); // Validate Table header diff --git a/tests/Functional/TalkTest.php b/tests/Functional/TalkTest.php index e4f70d0e..e9d4403e 100644 --- a/tests/Functional/TalkTest.php +++ b/tests/Functional/TalkTest.php @@ -57,7 +57,7 @@ public function testBrowsingTalks(): void self::assertResponseIsSuccessful(); // Validate Header - self::assertSelectorTextContains('h1.page-title', 'Talks'); + self::assertSelectorTextContains('[data-test-page-title]', 'Talks'); self::assertSelectorExists('a:contains("Create")'); // Validate Table header diff --git a/tests/Translations/FrenchTranslatedUiTest.php b/tests/Translations/FrenchTranslatedUiTest.php index e7c52842..b8921ff7 100644 --- a/tests/Translations/FrenchTranslatedUiTest.php +++ b/tests/Translations/FrenchTranslatedUiTest.php @@ -73,7 +73,7 @@ public function testBrowsingItems(): void self::assertResponseIsSuccessful(); // Validate Header - self::assertSelectorTextContains('h1.page-title', 'Livres'); + self::assertSelectorTextContains('[data-test-page-title]', 'Livres'); // Validate Table header self::assertSelectorTextContains('.sylius-table-column-title', 'Titre'); diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index 67f50628..223fef82 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -7,6 +7,7 @@ app: biz: Biz book: Book books: Books + browsing_speakers: Browsing speakers company_name: Company name conference: Conference conferences: Conferences diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index 8f6e5217..5d610739 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -7,6 +7,7 @@ app: biz: Biz book: Livre books: Livres + browsing_speakers: Parcourir les Conférencier-e-s company_name: Société conference: Conférence conferences: Conférences