Search code examples
twigorocrmorocommerce

How can I share some twig templates across all pages in Oro application?


I have some twig blocks and templates, that should be used all over the application. How can I achieve this in Oro app? I know there is a way to include twig from another folder with next syntax:

layout:
    actions:
        -   '@setBlockTheme':
                themes: ['casual.html.twig', '@SomeTheme/layouts/sometheme/common.html.twig']

But a flaw in this approach is the fact that I should include this common.html.twig in every yml file I want to use it.

Can I somehow add this common.html.twig file to all pages without this explicit inclusion?


Solution

  • You can put the layout update file to the Resources/views/layouts/<theme-name>/page/ folder in a bundle to apply it on every page.

    UPDATED:

    To use a template in all the pages you have to register it with setBlockTheme action using the layout update in the above directory. For more details see the Oro Documentation.