Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application template not looked for in theme directory #72

Open
armellarcier opened this issue Nov 20, 2020 · 1 comment
Open

Application template not looked for in theme directory #72

armellarcier opened this issue Nov 20, 2020 · 1 comment

Comments

@armellarcier
Copy link

armellarcier commented Nov 20, 2020

I have a route mapped to a template name

shop_domaines_show:
    path: /domaines/{slug}
    defaults:
        _controller: black_sylius_marketplace.controller.seller:showAction
        _sylius:
            template: 'Shop/views/domaines/show.html.twig'
            repository:
                method: findOneBySlug
                arguments:
                    - $slug

And a template in templates/Shop/views/domaines/show.html.twig

It works ok.

When I want to override this template in the theme it fails.

I put a new file in themes/MyTheme/Shop/views/domaines/show.html.twig

And it's not loaded.

If I remove the template in the templates dir, leaving only the one in the theme, here is the error I get :

Unable to find template "Shop/views/domaines/show.html.twig" (looked into: /project/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views, /project/templates, /project/templates, /project/vendor/symfony/twig-bridge/Resources/views/Form).

The loader is not looking in the theme directory. Note it seems to be looking twice in the /project/templates dir.

The problem only occurs for app templates.

Bundle templates are loaded fine from the theme directory. (/theme/MyTheme/SyliusShopBundle/views/Homepage/index.html.twig works perfetcly)

The theme is enabled of course

I'm using Sylius 1.8 and sylius/theme-bundle 1.5.1

@armellarcier
Copy link
Author

armellarcier commented Nov 20, 2020

A temporary fix is to add the theme directory to twig paths but it is not a solution

in config/packages/twig.yaml

twig:
    # DO NOT COMMIT THIS!
    paths: ['%kernel.project_dir%/themes/MyTheme', '%kernel.project_dir%/templates']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant