Skip to content

Commit

Permalink
[Docs] Use dynamic titles
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Jan 8, 2025
1 parent 216fe4e commit 881d1f3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/Story/DefaultBooksStory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public function build(): void
BookFactory::new()
->withTitle('1984')
->withAuthorName('George Orwell')
->create()
;

BookFactory::new()
->withTitle('Lord of the Flies')
->withAuthorName('William Golding')
->create()
;

BookFactory::createMany(20);
Expand Down
Binary file added docs/.gitbook/assets/show_book_title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 24 additions & 1 deletion docs/cookbook/admin_panel/page_titles.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,36 @@ We're going to reuse this hook and its template in our config file and add a `he
sylius_twig_hooks:
hooks:
# ...
'sylius_admin.speaker.index.content.header.title_block':
'sylius_admin.speaker.index.content.header.title_block': # The speaker index 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
```
<div data-full-width="false">
<figure><img src="../../.gitbook/assets/show_book_title.png" alt="Show book title"></figure>
</div>
Note that you can also use [Symfony Expression Language](https://symfony.com/doc/current/components/expression_language.html) in the configuration key for dynamic titles:
```yaml
# config/packages/sylius_bootstrap_admin_ui.yaml
# ...
sylius_twig_hooks:
hooks:
# ...
'sylius_admin.book.show.content.header.title_block': # The show page title block
title:
template: '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/title.html.twig'
configuration:
title: '@=_context.book.getTitle()' # Use the current book title
```
`@=_context` contains all the current Twig vars.

## Adding an icon

<div data-full-width="false">
Expand Down

0 comments on commit 881d1f3

Please sign in to comment.