I'm trying to override the FOSUserBundle Templates as show here:
https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_templates.md
I used the second method, I created my own bundle and put the templates in
myBundle/Resources/Views/Security/login.html.twig
and
myBundle/Resources/Views/Registration/register.html.twig.
both templates start with:
{% extends "::nologbase.html.twig" %}
where nologbase.html.twig is defined in app/Resourcer/views.
well, the first one (login) is correctly displayed but the second one (register) shows row html with no css.
I cleared the cache and I also tried to display only the extended template and compared the source code. it is exactly the same!
any idea?
thanks
Related
I want to override the default SonataAdmin Template.
I create a standard_layout.html.twig in my Namespace/bundle/resources/views
(same structur, same file name, same content)
I copied all the content of the source template in my target template, i just edit some part of the target off course....and nothing
thanks for your help
Bye
You have the solution of bundle heritance http://symfony.com/doc/current/cookbook/bundles/inheritance.html which allows, not only override templates but methods too.
Or you have http://symfony.com/doc/2.0/book/templating.html#overriding-bundle-templates which focusing only on templates.
With this last, you can try to create :
app/Resources/SonataAdminBundle/views/CRUD/base_show_field.html.twig
I'm learning symfony2 and like it very much (migrating from ZendFramework 1.x) but I'm stuck now with twig templating. Can you point me to the right direction?
My application has many customers and each has some customization (mostly templates, but also controllers, etc.).
I try to achieve this by bundle inheritance / I created ClientBundle which inherits from BaseBundle holding all basic code and templates... it works as I need for everything bud templates. When I create template in ClientBundle it overlays the template from BaseBundle and I cannot get access from the ClientBundle template to the original template from BaseBundle. I would like to extend the parent template, not overlay it... is this impossible?
Thank you!
Using the standard Symfony extends notation to reference a parent's bundle template results in fatal error. Symfony interprets your template reference to BaseBundle as ChildBundle as a result of bundle inheritance causing a function nesting level exception.
You can reference the parent's bundle template file directly using the following notation:
{% extends "#Client/Foo/bar.html.twig" %}
in replacement for:
{% extends "ClientBundle:Foo:bar.html.twig" %}
Twig's FilesystemLoader splits the reference string into namespace (Client) and path (Foo/bar.html.twig). Namespace is your bundle name without the Bundle suffix. Full path for each namespace is resolved by concatenating default <bundle_path>/Resources/views/ with supplied path.
The standard command in twig template for extention is:
{% extends 'BaseBundle::yourTemplate.html.twig' %}
You probably use the same name for template in your child bundle (you probably have a yourTemplate.html.twig in both your parent and your child bundle so the child template overrides the parent). In this case, you can rename your child template (yourTemplate2.html.twig) and then extend the child template from parent. More about bundles inheritance and twig templates extentions:
http://symfony.com/doc/current/cookbook/bundles/inheritance.html
http://symfony.com/doc/current/book/templating.html
I'm using SonataBlockBundle in my current project.
I create a SimpleBlock and render it in my twig template with something like
{{ sonata_block_render('name' : 'myBlock') }}.
But the block consists of title and body, is there a way to render title and body separately, like I can do with form fields?
Thank you in anticipation!
The best way to go there would be to create a custom BlockService (see http://sonata-project.org/bundles/block/master/doc/reference/your_first_block.html for instructions about that), with a custom twig template where you will be able to specify your title/body rendering.
How can I create a reusable panel based on http://getbootstrap.com/components/#panels-heading in Symfony 2 and Twig? I mean how to create resusable control that I can embed in my twig page and provide to it header text and body, which will contain html and some other twig components (e.g. form controls).
This control should contain all the HTML that come from bootstrap panel example and I will only provide header text and body ... and control put this in appropriate place.
http://twig.sensiolabs.org/doc/tags/extends.html
Are you talking about extending templates? That way you can reuse all the HTML that came from bootstrap and just overwrite the sections you need.
In Symfony2 the extends syntax is something like:
somefile.twig.html
{% extends 'AcmeSomeBundle:Default:bootstrap.template.html.twig' %}
Look at the documentation link above for more details.
I want to override the default SonataAdmin Template.
I create a standard_layout.html.twig in my Namespace/bundle/resources/views
(same structur, same file name, same content)
I copied all the content of the source template in my target template, i just edit some part of the target off course....and nothing
thanks for your help
Bye
You have the solution of bundle heritance http://symfony.com/doc/current/cookbook/bundles/inheritance.html which allows, not only override templates but methods too.
Or you have http://symfony.com/doc/2.0/book/templating.html#overriding-bundle-templates which focusing only on templates.
With this last, you can try to create :
app/Resources/SonataAdminBundle/views/CRUD/base_show_field.html.twig