Skip to content

Update doc #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% code title="src/Menu/MenuBuilder.php" lineNumbers="true" %}

{% 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cool to have php example as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, and maybe a small screeenshot of the browser tab as well to make it extra explicit?

# ...
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 %}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

## Changing the default title for a specific page

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