Question

I've installed SonataAdminBundle and SonataUserBundle and I'm trying to override some twig templates. I've done succesfully with all except with user_block.html.twig

This is my proyect ../app/Resources/ directory structure:

Resources/
├── ApplicationSonataUserBundle
│   └── views
│       ├── Admin
│       │   └── Core
│       │       └── user_block.html.twig   <--- it doesn't work
│       ├── layout.html.twig
│       ├── Profile
│       │   ├── action.html.twig
│       │   ├── edit_authentication.html.twig
│       │   ├── edit_profile.html.twig
│       │   └── show.html.twig
│       └── Security
│           └── login.html.twig
├── SonataAdminBundle
│   └── views
│       └── standard_layout.html.twig
└── TwigBundle
    └── views
        └── Exception
            └── error.html.twig

Also I've tried put it under SonataAdminBundle or SonataUserBundle directory but nothing, it didn't work for me.

How can I override user_block template?

Thanks

Was it helpful?

Solution 2

Answer

The directory file structure shown before works fine. I've solved the problem just adding the necessary js and css on standard_layout.html.twig

{% block stylesheets %}
            ...

            <!-- custom stylesheets -->
            <link rel="stylesheet" href="{{ asset('bundles/mybundle/css/mycssfile.css') }}" media="all">

{% endblock %}

{% block javascripts %}
            ...
            <!-- custom js -->
            <script src="{{ asset('bundles/mybundle/js/myscriptfile.css') }}"></script>

{% endblock %}

OTHER TIPS

Alternatively, you can use the configuration, like this :

sonata_admin:
    templates:
        layout:                 
        user_block: '::Admin/user_block.html.twig'

And then put your template here : app/Resources/views/Admin/user_block.html.twig

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top