Skip to content

Commit dd37327

Browse files
committed
Update doc
1 parent 08057ed commit dd37327

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

docs/.gitbook/assets/custom_title.png

20.9 KB
Loading

docs/cookbook/admin_panel/menu.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,41 @@ final readonly class MenuBuilder implements MenuBuilderInterface
8888
}
8989
}
9090
```
91+
92+
### Opening a link in a new tab
93+
94+
You can make a link open in a new browser tab by adding the `target="_blank"` link attribute to menu items. This can be applied to top-level menu items without children, or to child items themselves. In other words, it only works for items that do not have submenus.
95+
96+
To configure this behavior, set the target link attribute on the menu item as shown below:
97+
98+
{% code title="src/Menu/MenuBuilder.php" lineNumbers="true" %}
99+
```php
100+
// ...
101+
#[AsDecorator(decorates: 'sylius_admin_ui.knp.menu_builder')]
102+
final readonly class MenuBuilder implements MenuBuilderInterface
103+
{
104+
// ...
105+
106+
public function createMenu(array $options): ItemInterface
107+
{
108+
$menu = $this->factory->createItem('root');
109+
// ...
110+
$this->addYourWebsitebMenu($menu);
111+
112+
return $menu;
113+
}
114+
115+
private function addYourWebsitebMenu(ItemInterface $menu): void
116+
{
117+
$apiDoc = $menu
118+
->addChild('your_website', [
119+
'route' => 'app_homepage',
120+
])
121+
->setLabel('app.ui.your_website')
122+
->setLabelAttribute('icon', 'tabler:arrow-up-right')
123+
->setLinkAttribute('target', '_blank') // Opens the link in a new tab
124+
;
125+
}
126+
}
127+
```
128+
{% endcode %}

docs/cookbook/admin_panel/page_titles.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
11
# Customizing the page titles
22

3+
## Defining the application base title
4+
5+
The application’s base title can be configured using the `sylius_admin.base#base_title` Twig hook. Here's an example of how to define it:
6+
7+
<div data-full-width="false">
8+
9+
<figure><img src=".gitbook/assets/custom_title.png" alt="Example of a Custom Title in Google Chrome"></figure>
10+
11+
</div>
12+
13+
{% tabs %}
14+
{% tab title="YAML" %}
15+
{% code title="config/packages/sylius_bootstrap_admin_ui.yaml" lineNumbers="true" %}
16+
```yaml
17+
# ...
18+
sylius_twig_hooks:
19+
hooks:
20+
'sylius_admin.base#base_title': # The base title block
21+
default:
22+
configuration:
23+
title: 'My app' # here is our title override
24+
```
25+
{% endcode %}
26+
{% endtab %}
27+
28+
{% tab title="PHP" %}
29+
{% code title="config/packages/sylius_bootstrap_admin_ui.php" lineNumbers="true" %}
30+
```php
31+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
32+
33+
return static function (ContainerConfigurator $containerConfigurator): void {
34+
// ...
35+
$containerConfigurator->extension('sylius_twig_hooks', [
36+
'hooks' => [
37+
// The base title block
38+
'sylius_admin.base#base_title' => [
39+
'default' => [
40+
'configuration' => [
41+
'title' => 'My app' // here is our title override
42+
],
43+
],
44+
],
45+
],
46+
]);
47+
};
48+
```
49+
{% endcode %}
50+
{% endtab %}
51+
{% endtabs %}
52+
353
## Changing the default title for a specific page
454

555
<div data-full-width="false">

0 commit comments

Comments
 (0)