Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/.gitbook/assets/custom_title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions docs/cookbook/admin_panel/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,41 @@ final readonly class MenuBuilder implements MenuBuilderInterface
}
}
```

### Opening a link in a new tab

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.

To configure this behavior, set the target link attribute on the menu item as shown below:

{% code title="src/Menu/MenuBuilder.php" lineNumbers="true" %}
```php
// ...
#[AsDecorator(decorates: 'sylius_admin_ui.knp.menu_builder')]
final readonly class MenuBuilder implements MenuBuilderInterface
{
// ...

public function createMenu(array $options): ItemInterface
{
$menu = $this->factory->createItem('root');
// ...
$this->addYourWebsitebMenu($menu);

return $menu;
}

private function addYourWebsitebMenu(ItemInterface $menu): void
{
$apiDoc = $menu
->addChild('your_website', [
'route' => 'app_homepage',
])
->setLabel('app.ui.your_website')
->setLabelAttribute('icon', 'tabler:arrow-up-right')
->setLinkAttribute('target', '_blank') // Opens the link in a new tab
;
}
}
```
{% endcode %}
50 changes: 50 additions & 0 deletions docs/cookbook/admin_panel/page_titles.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# Customizing the page titles

## Defining the application base title

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:

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

<figure><img src=".gitbook/assets/custom_title.png" alt="Example of a Custom Title in Google Chrome"></figure>

</div>

{% tabs %}
{% tab title="YAML" %}
{% code title="config/packages/sylius_bootstrap_admin_ui.yaml" lineNumbers="true" %}
```yaml
# ...
sylius_twig_hooks:
hooks:
'sylius_admin.base#base_title': # The base title block
default:
configuration:
title: 'My app' # here is our title override
```
{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code title="config/packages/sylius_bootstrap_admin_ui.php" lineNumbers="true" %}
```php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// ...
$containerConfigurator->extension('sylius_twig_hooks', [
'hooks' => [
// The base title block
'sylius_admin.base#base_title' => [
'default' => [
'configuration' => [
'title' => 'My app' // here is our title override
],
],
],
],
]);
};
```
{% endcode %}
{% endtab %}
{% endtabs %}

## Changing the default title for a specific page

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