-
Notifications
You must be signed in to change notification settings - Fork 12
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
[Docs] Init a cookbook #128
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d3c45ad
[Docs] Init a cookbook
loic425 57e5e16
Add admin menu customization
vasilvestre 080eb6e
Adapt logo customization with 0.6
loic425 91d67e5
Add the YAML version of the config
loic425 27b829e
Update docs/cookbook/admin_panel/index.md
loic425 eea448a
Update docs/cookbook/admin_panel/index.md
loic425 98583cf
Same rephrasing
loic425 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# How to customize your admin panel | ||
|
||
## How to customize the sidebar logo | ||
|
||
To customize the sidebar logo, you need to set new logo template at `sylius_admin.common.component.sidebar.logo` twig hook. | ||
Choose the YAML or the PHP version. | ||
|
||
```yaml | ||
# config/packages/sylius_bootstrap_admin_ui.yaml | ||
# ... | ||
sylius_twig_hooks: | ||
hooks: | ||
# ... | ||
'sylius_admin.common.component.sidebar.logo': | ||
image: | ||
# template: '@SyliusBootstrapAdminUi/shared/crud/common/sidebar/logo/image.html.twig' | ||
template: 'shared/crud/common/sidebar/logo/image.html.twig' | ||
|
||
``` | ||
|
||
```php | ||
// config/packages/sylius_bootstrap_admin_ui.php | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
// ... | ||
|
||
// Add these following lines to define your own Twig template for the logo. | ||
$containerConfigurator->extension('sylius_twig_hooks', [ | ||
'hooks' => [ | ||
'sylius_admin.common.component.sidebar.logo' => [ | ||
'image' => [ | ||
// 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/sidebar/logo/image.html.twig', | ||
'template' => 'shared/crud/common/sidebar/logo/image.html.twig', | ||
], | ||
], | ||
], | ||
|
||
]); | ||
}; | ||
|
||
``` | ||
|
||
```twig | ||
{# templates/shared/crud/common/sidebar/logo/image.html.twig #} | ||
|
||
<img src="{{ asset('images/logo.png') }}" alt="Your Brand name" class="navbar-brand-image" /> | ||
|
||
``` | ||
|
||
## How to customize the login page logo | ||
|
||
To customize the login page logo,you need to set new logo template at `sylius_admin.security.login.logo` twig hook. | ||
Choose the YAML or the PHP version. | ||
|
||
```yaml | ||
# config/packages/sylius_bootstrap_admin_ui.yaml | ||
# ... | ||
sylius_twig_hooks: | ||
hooks: | ||
# ... | ||
'sylius_admin.security.login.logo': | ||
image: | ||
# template: '@SyliusBootstrapAdminUi/security/common/logo/image.html.twig' | ||
template: 'security/common/logo/image.html.twig' | ||
|
||
``` | ||
|
||
```php | ||
// config/packages/sylius_bootstrap_admin_ui.php | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$containerConfigurator->import('@SyliusBootstrapAdminUiBundle/config/app.php'); | ||
|
||
// Add these following lines to define your own Twig template for the logo. | ||
$containerConfigurator->extension('sylius_twig_hooks', [ | ||
'hooks' => [ | ||
'sylius_admin.security.login.logo' => [ | ||
'image' => [ | ||
// 'template' => '@SyliusBootstrapAdminUi/security/common/logo/image.html.twig' | ||
'template' => 'security/common/logo/image.html.twig', | ||
], | ||
], | ||
], | ||
]); | ||
}; | ||
``` | ||
|
||
```twig | ||
<img src="{{ asset('images/logo.png') }}" alt="Your Brand name" class="sylius navbar-brand-image"> | ||
|
||
``` | ||
|
||
## How to customize the admin menu | ||
|
||
You should decorate the `sylius_admin_ui.knp.menu_builder` service to customize the admin menu. | ||
|
||
```php | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Menu; | ||
|
||
use Knp\Menu\FactoryInterface; | ||
use Knp\Menu\ItemInterface; | ||
use Symfony\Component\DependencyInjection\Attribute\AsDecorator; | ||
|
||
#[AsDecorator(decorates: 'sylius_admin_ui.knp.menu_builder')] | ||
final readonly class MenuBuilder | ||
{ | ||
public function __construct( | ||
private readonly FactoryInterface $factory, | ||
) { | ||
} | ||
|
||
public function createMenu(array $options): ItemInterface | ||
{ | ||
$menu = $this->factory->createItem('root'); | ||
|
||
$menu | ||
->addChild('dashboard', [ | ||
'route' => 'sylius_admin_ui_dashboard', | ||
]) | ||
->setLabel('sylius.ui.dashboard') | ||
->setLabelAttribute('icon', 'dashboard') | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Cookbook | ||
|
||
* [How to customize your admin panel](admin_panel/index.md) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.