The main layout file is src/BD/TestBundle/views/layout.html.twig.
I'm trying to extend it from a file located in src/BD/TestBundle/views/Default/index.html.twig.
{% 'BDTestBundle::layout.html.twig' } throws a unable to find the template error message.
Any ideas?
It should be {% extends 'TestBundle:Default:layout.html.twig' %}
TestBundle bundle name
Dedault directory name in Resources
layout:html:twig template name
Related
Website : Open source frameword based on Symfony 2.7
My entitie : Entity/Download.php (with properties "id", "creation_date" and "name")
I'm working on my own Bundle and I try to create a new datagrid based on my own entitie, I follow this tutorial. Below is what I've done :
Create /resources/config/datagrid.yml, with a very light datagrid.
Edit DependencyInjection/MyBundleExtension.php to load datagrid.yml.
Edit my twig view to render the datagrid :
{% import 'PimDataGridBundle::macros.html.twig' as dataGrid %}
{% block content %}
{{ dataGrid.renderGrid('custom_download', { localeCode: locale_code() }) }}
{% endblock %}
But this error is generated :
Twig_Error_Runtime: "An exception has been thrown during the rendering
of a template ("A configuration for "custom_download" datagrid was not
found.
-> If I try the same code with another gridname already existing that works then I believe the problem comes from my new datagrid but I don't understand what's wrong : does the kernel include my YML config file ? I don't think so.
Thanks for your help.
You create datagrid.yml in /resources/config folder.
But according OroPlatform conventions configuration file should be placed in Resources/config/oro folder of your bundle and named datagrids.yml.
Exactly in this path OroPlatform is looking for datagrid configuration.
https://github.com/oroinc/platform/blob/2.5/src/Oro/Bundle/DataGridBundle/Provider/ConfigurationProvider.php#L154-L160
Please move your configuration into correct directory and filename. And It will be work. And of course you should remove this file loading from DependencyInjection/MyBundleExtension.php OroPlatform do it automatically.
For more detailed understanding how you can use OroPlatform datagrid features please read bundle documentation
https://github.com/oroinc/platform/blob/2.5/src/Oro/Bundle/DataGridBundle/Resources/doc/backend/datagrid.md
I'm pretty new to Symfony development and i just tried to use the FOSUserBundle. I followed the guide Getting Started With FOSUserBundle on the official Symfony website.
Afterwards i wanted to test the functionality of the installation and visited the link www.linktomytestproject.dev/login which worked flawlessly. But when i tried to visit www.linktomytestproject.dev/register to test the registration functionality, i got the following errormessage:
Unable to find template "register_content.html.twig" (looked into: /home/vagrant/mytestproject/app/Resources/views, /home/vagrant/mytestproject/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form) in #FOSUser/Registration/register.html.twig at line 4.
500 Internal Server Error - Twig_Error_Loader
I checked the file register.html.twig, which contains the following code:
{% extends "#FOSUser/layout.html.twig" %}
{% block fos_user_content %}
{% include "register_content.html.twig" %}
{% endblock fos_user_content %}
When I change the third line into:
{% include "FOSUserBundle:Registration:register_content.html.twig" %}
The file is found correctly and i can use the registration functionality as intended.
But the change i made is inside the vendor folder, which obviously isn't affected by any means of version control. So i guess there has to be a place somewhere in the configuration files, where this file/foldermapping is affected.
I would really appreciate it, if someone could help me out with this question, even though this is probably a really basic problem.
First override the FOSUserBundle http://symfony.com/doc/current/bundles/FOSUserBundle/overriding_controllers.html
After that, you can create view folders like in vendor and you can use views like that;
{% include "YourBundle:Registration:register_content.html.twig" %}
It's a bug a issue is open on github
Is a bundle issue, in my project I change on the file
\vendor\friendsofsymfony\user-bundle\Resources\views\Registration\register.html.twig
this
{% include "register_content.html.twig" %}
for this
{% include "#FOSUser/Registration/register_content.html.twig" %}
I have a Twig template in this folder structure
appName
app
resources
FosUserBundle
views
myTemplate.html.twig
views
Form
templateToRefer.html.twig
from -myTemplate.html.twig- I would like to reference -templateToRefer.html.twig- that is inside folder views that is brother of FosUserBundle folder. Is there any way to do it?
My way is this
{% form_theme form 'Form/fields.html.twig' %}
but I always get error
Unable to find template "Form/fields.html.twig" (looked into: /home/felpone/Scrivania/appName/app/Resources/views
you need to pass the full path 'AppBundle:Form:templateToRefer.html.twig'
On my eZ publish 5 site I have all my templates in Twig, in the vendor/ezsystems/demobundle/EzSystems/DemoBundle/Resources/views/ subfolders. They are all being used throughout my whole site, no problems there. With one exception: 404 pages. If I go to mysite/nonexistingurl, it gives me a kernel (20) / Error page, with status 404. The template being used for this is the 20.tpl somewhere in eZ publish/symfony, I don't want that, I want to use my own Twig template for this.
How can I achieve this? I added a vendor/ezsystems/demobundle/EzSystems/DemoBundle/Resources/views/Exception/error.html.twig page, but this one is not being called
first add this configuration parameter
parameters:
ezpublish_legacy.default.module_default_layout: 'YourBundle::pagelayout_legacy.html.twig'
you may add it in the parameters.yml file located in path/to/yourezpublishinstall/ezpublish/config, the parameters.yml is usually imported in the config.yml located in the same folder
this would define the twig template located in path/to/yourbundle/Resources/views/pagelayout_legacy.html.twig as the parent template for legacy stack modules templates
inside the pagelayout_legacy.html.twig template, you may use this code
{% extends 'YourBundle::pagelayout.html.twig' %}
{% block content %}
{# module_result variable is received from the legacy controller. #}
{% if module_result.errorCode is defined %}
<h1>{{ module_result.errorMessage }} ({{ module_result.errorCode }})</h1>
{% else %}
{{ module_result.content|raw }}
{% endif %}
{% endblock %}
note in the code, the template extends the pagelayout.html.twig template, that should here define a block named content, the pagelayout.html.twig may usually be the main base layout for your ez publish 5 website
you may modify the pagelayout_legacy.html.twig template to your needs
reference:
http://share.ez.no/forums/developer/overriding-legacy-error-pages-templates
I am new to symfony and I am trying to make some tests.
My first test is to make a page including header and footer.
I have created controllers files in bundle:
DefaultController.php
FooterController.php
SecurityController.php
for the login tests.
I have also created three twig files in
"Resources/views/Default"
footer.html.twig
head.html.twig
index.html.twig
Now for first, I have tried to include in index.html.twig the file footer.html.twig, with the code:
{% extends 'AcmeSecurityBundle:Default:footer.html.twig' %}
Now, if there is only text or tags, all works better. But if i declare in the footer controller some vars and put this code in the twig file:
{{ year }}
{{ lastyear }}
{{ copyright }}
Symfony gets me the 500 Internal Error, with
"Variable "year" does not exist in AcmeSecurityBundle:Default:footer.html.twig at line 7" message.
How can Ipass FooterController.php variables in a twig inclusion?