Closed slince closed 6 years ago
Well, what is 'AcmeBundle::layout.html.twig
? Maybe you're not extending the right templates?
AcmeBundle::layout.html.twig
is a basic layout template. like
<html>
<head>admin</head>
<body>
<div class="content-wrapper">
<section class="content-header">
{% block pageHeader %}{% endblock %}
{{ breadcrumb(admin_breadcrumb)|raw }}
</section>
<section class="content">
{% block content %}{% endblock %}
</section>
</div>
</body>
Is the first template overriding the bundle one? Could you tell me the name of first template and the path? Thanks.
Is the first template overriding the bundle one
No,
this is my controller code.
/**
* 用户管理列表
*
* @Route("/users", name="admin_user_index")
*/
public function indexAction()
{
$this->breadcrumb->push('admin.user.index');
$grid = $this->gridFactory->get(User::class);
return $grid->getGridResponse('AcmeBundle:User:index.html.twig');
}
Ok, so if it is not overriding, how do you expect this to work? That's not an issue with the bundle but an issue with your code.
I'm closing this.
hi, can you tell me how to do so it can work.
Sorry, my fault, you don't need to extend or override anything. It seems like the DataGridExtension
isn't registered. Weird.
DataGridExtension
has been registered. it can work using default theme.
...
{{ grid(grid) }}
...
So I think it's not an issue of this bundle
ok, can you tell me some core code about "self template". so i can debug it by myself.
You can view all the logic starting from DataGridExtension
I think it's because beacause the _self
variable return the current template name, not the template instance from twig 2.0.0
Hi,
I am a little confused. i don't know why getTemplatesFromString
need to find parents of the template.
i think it's not necessary, you know, blocks in the parent template can be overwritten by the current template.
Sorry, ATM I'm not able to take a look at this due to my little free time and due to the fact I'm the only devel that's following the project but I didn't wrote it. If you want to submit a PR, you're welcome but I really don't know if and when I'll have the time to look and eventually merge it.
Hi, i have expanded the class DataGridExtension
and rewritten method getTemplates
like this:
protected function getTemplates(Twig_Environment $environment)
{
if ($this->templates) {
return $this->templates;
}
$this->templates[] = $environment->load($this->defaultTemplate);
if ($this->theme) {
if (!$this->theme instanceof \Twig_Template && !$this->theme instanceof \Twig_TemplateWrapper) {
$template = $environment->load($this->theme);
} else {
$template = $this->theme;
}
arrau
array_unshift($this->templates, $template);
}
return $this->templates;
}
and it works now for me. if you think this is ok, i will submit a pr. 😃
This is my template:
error:
it does not work like the follow:
Looking forward to your reply.