LiipThemeBundle icon indicating copy to clipboard operation
LiipThemeBundle copied to clipboard

Theme templates for core bundle are not being found

Open vhejda opened this issue 10 years ago • 4 comments

Hello! I have tried everything already, but I can't seem to get this bundle to work properly. I have this config:

# app/config/config.yml

liip_theme:
    themes: ["Default","Plain"]
    active_theme: "Default"

My application core parts are in src\Core\CoreBundle. I also have a BannerBundle in vendor directory, at for this bundle the themes work just as expected...

I am trying to override my footer template: src\Core\CoreBundle\Resources\views\Footer\footer.html.twig. I tried creating a new template in all 3 ways described in documentation:

Override themes directory: app/Resources/themes/Default/CoreBundle/Footer/footer.html.twig Override view directory: app/Resources/CoreBundle/views/Footer/footer.html.twig Bundle theme directory: src/Core/CoreBundle/Resources/themes/Default/Footer/footer.html.twig

...but only the second one works, which is natural Symfony behavior and does not let me create any different themes. For the BannerBundle all these 3 ways override my default template in correct order.

Am I doing something wrong? Or does the theme bundle have problems with the structure of CoreBundle? In docs you say src\BundleName\Resources directly, but I have Core directory between this... I also tried adding the CoreBundle folder inside Core folder in the themes structure, but that doesn't help either.

Thank you in advance!

vhejda avatar May 19 '15 09:05 vhejda

If you wanna override vendors template it must go either into app folder. or you should inherit bundle that you wanna override

  • http://symfony.com/doc/current/cookbook/bundles/inheritance.html#overriding-resources-templates-routing-etc
  • http://symfony.com/doc/current/book/templating.html#overriding-bundle-templates

oleg-andreyev avatar May 19 '15 09:05 oleg-andreyev

Oleg: No, I want to override my own templates located in src/Core/CoreBundle/Resources/views with different themes (default, plain etc.). None of the ways proposed in the docs here works for me. Thanks!

EDIT: For the record, I call this template this way: $this->render("@Core/Footer/footer.html.twig");. But neither themes\Default\CoreBundle\Footer\footer.html.twig, nor themes\Default\Core\CoreBundle\Footer\footer.html.twig, nor themes\Default\Core\Footer\footer.html.twig overrides the default template. Those are all the combinations that make sense to me...

vhejda avatar May 19 '15 09:05 vhejda

Then probably you need cascading, you need to specify paths where FileLocator should look.

https://github.com/liip/LiipThemeBundle#change-theme-cascading-order

oleg-andreyev avatar May 19 '15 12:05 oleg-andreyev

Oleg: Thank you very much for your time, but I have found a different way to make it work. Calling $this->render("@Core/Footer/footer.html.twig");seemed to be the "error". I had to change all render calls in my controllers to this format: $this->render("CoreBundle:Footer:footer.html.twig");, and it works. I do not know, if this is a bug, or feature/desired behavior :) I will let you decide.

Thank you anyway for this great bundle, keep up the awesome work!

Vojta

vhejda avatar May 19 '15 12:05 vhejda