1
votes

The documentation for Sonata Admin Bundle offers this method for setting per-admin templates: https://sonata-project.org/bundles/admin/2-0/doc/reference/templates.html

However that method has now been deprecated. Is there a new method, not mentioned yet in the documentation, or have the devs simply jumped the gun with this deprecation?

1
This is an old post, but just in case ... github.com/sonata-project/SonataAdminBundle/pull/6766 ... So the decrepation has been moved to 5.0. The next one 4.0 which is coming soon will still support the old setTemplate.Andy

1 Answers

-1
votes

You can define your custom template for each admin by using the following code in your admin class.

public function configure()
{
    $this->setTemplate('show', 'sonata_admin/show.html.twig');
    // similarly for all actions
}

You must place your twig file in templates/sonata_admin/ folder, if you are using symfony 4.

The twig file must be like,

{% extends '@SonataAdmin/CRUD/show.html.twig' %}

{% block block_name %}
//your content
{% endblock %}