liip / LiipThemeBundle

Provides theming support for Symfony bundles
MIT License
290 stars 76 forks source link

Theme templates for core bundle are not being found #124

Open vhejda opened 9 years ago

vhejda commented 9 years ago

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!

oleg-andreyev commented 9 years ago

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

vhejda commented 9 years ago

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...

oleg-andreyev commented 9 years ago

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

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

vhejda commented 9 years ago

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