How to use a single @layout for all modules
- simonjcarr
- Member | 28
Not sure if am missing something, but it seems that I have put a copy of @layout.latte in the templates directory of every module. But if I decide to change my site layout, I might have 50 files to update.
Is there a way I can put put a @layout.latte file in the Modules folder so that all modules use one layout file.
Last edited by simonjcarr (2015-11-01 20:22)
- simonjcarr
- Member | 28
The only way I have found to do it so far is to include this line in all my views, but it is not very nice.
This uses the file app\modules\@layout.latte
Is there a better way?
- David Matějka
- Moderator | 6445
Just override formatLayoutTemplateFiles method in your base presenter like this:
- simonjcarr
- Member | 28
I have now have the following code in /app/presenters/BasePresenter.php
But the layout is not being used.
Also when I tried to use protected instead of public, I got the following error
Last edited by simonjcarr (2015-11-01 21:16)
- David Matějka
- Moderator | 6445
oh, sorry I didn't noticed it must be public. So just change the
“protected” to the “public”. And using “/app” will probably not
work, use path relative to the location of the base presenter,
e.g __DIR__ . '/../modules/@layout'
- simonjcarr
- Member | 28
Very strange,
Overriding the formatLayoutTemplateFiles method does not seem to work, however if I change the code in core to include the my folder in the returned array it does work.