Created
September 26, 2014 08:04
-
-
Save webdevilopers/2e4455c69d258c5fdca9 to your computer and use it in GitHub Desktop.
Override list view twig template in SonataAdminBundle
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
# Acme\DemoBundle\Resources/config/admin.yml | |
services: | |
sonata.admin.foo: | |
class: Acme\DemoBundle\Admin\FooAdmin | |
tags: | |
- { name: sonata.admin, manager_type: orm, group: "Foo", label: "Foo" } | |
arguments: | |
- ~ | |
- Acme\DemoBundle\Entity\Foo | |
- ~ | |
calls: | |
- [ setTemplate, [list, AcmeDemoBundle:FooAdmin:list.html.twig]] |
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
<?php | |
namespace Acme\DemoBundle\Admin; | |
use Sonata\AdminBundle\Admin\Admin; | |
class FooAdmin extends Admin | |
{ | |
public function getTemplate($name) | |
{ | |
switch ($name) { | |
case 'list': | |
return 'Acme\DemoBundle:FooAdmin:list.html.twig'; | |
break; | |
default: | |
return parent::getTemplate($name); | |
break; | |
} | |
} | |
} |
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
# AcmeDemoBundle:FooAdmin:list.html.twig | |
{% extends 'SonataAdminBundle:CRUD:base_list.html.twig' %} | |
{% block list_header %} | |
Here is a list Foos: | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add function in FooAdmin is not utils :)