1
votes

Context

I'm trying to override the following template : vendor/oro/platform/src/Oro/Bundle/OrganizationBundle/Resources/views/BusinessUnit/update.html.twig

This template seems to belong to the OroOrganizationBundle bundle.

Issue

So, I have tried to put my override in the following path : templates/bundles/OroOrganizationBundle/BusinessUnit/update.html.twig according to Symfony 4.X documentation : https://symfony.com/doc/4.4/bundles/override.html#templates

I have cleared the cache : symfony console cache:clear but nothing changes.

Here is my override template :

{% extends 'OroOrganizationBundle:BusinessUnit:update.html.twig' %}

{% block content_data %}
    {% set id = 'business_unit-profile' %}
    {% set dataBlocks = [{
        'title': 'General'|trans,
        'class': 'active',
        'subblocks': [{
            'title': '',
            'data': [
                form_widget(form.appendUsers, {'id': 'businessUnitAppendUsers'}),
                form_widget(form.removeUsers, {'id': 'businessUnitRemoveUsers'}),
                form_row(form.name),

                form_row(form.parentBusinessUnit),

                form_row(form.phone),
                form_row(form.website),
                form_row(form.email),
                form_row(form.fax),
            ]
        }]
    }] %}

    {% set dataBlocks = dataBlocks|merge(oro_form_additional_data(form, 'Additional Override'|trans)) %}

    {% set dataBlocks = dataBlocks|merge([{
        'title' : 'oro.organization.businessunit.users.label'|trans,
        'subblocks': [{
            'title' : null,
            'useSpan': false,
            'data' : [dataGrid.renderGrid(gridName, {business_unit_id: entityId}, { cssClass: 'inner-grid' })]
        }]
    }] ) %}

    {% set data = {
        'formErrors': form_errors(form)? form_errors(form) : null,
        'dataBlocks': dataBlocks
    } %}

    {{ parent() }}
{% endblock content_data %}

Here is the output of the following command line : symfony console debug:twig | grep Organization

enter image description here

1
Try setting the extends to your layout file and not the bundles. - Robert Saylor
Thanks but I think that my problem came from this path templates/bundles/OroOrganizationBundle/BusinessUnit/. OroPlatform don't seems to read the file.. - Louis Bertin
Use 'bin/console debug:twig' to see the list of directories that twig uses for templates and the order in which they are searched. - Cerad
That's strange.. here is the output of the following command line : symfony console debug:twig | grep Organization . Symfony seems to look into this folder.. upload.vaa.red/2i9PM7#af0976ea2bd9833cafb6201d4f3bb448 - Louis Bertin
Instead of a link, consider updating your question. At least I am assuming it is a link. It would be unusual for twig to load templates from an external website. - Cerad

1 Answers

2
votes

Finally, I found a solution using this article from Oro documentation : https://doc.oroinc.com/frontend/back-office/templates/

The right path for my case was : src/Resources/OroOrganizationBundle/views/BusinessUnit/update.html.twig

I have tried to use the "extends" method from the Symfony documentation : https://symfony.com/doc/4.4/bundles/override.html#templates which consist to override only a specific block part. In my case, I needed to copy the entire file but it works.