-
Notifications
You must be signed in to change notification settings - Fork 113
4. Extending Themes
You can set a theme to extend an other. Check section How to Create a theme for instructions. A child theme may override parent's theme Assets and Views.
When you are requesting a view/asset that doesn't exist in your active theme, then it will be resolved from it's parent theme. You can easily create variations of your theme by simply overriding your views/themes that are different.
This is example will help you understand the theme hierarcy behaviour:
\public
+- image1.jpg
|
+- \ThemeA
| +- image2.jpg
| +- image3.jpg
|
+- \ThemeB // (Also it Extends ThemeA)
+- image3.jpg
Consider these scenarios:
Theme::Set('ThemeA'); // ThemeA is Active
theme_url('image1.jpg'); // = /image1.jpg
theme_url('image2.jpg'); // = /ThemeA/image2.jpg
theme_url('image3.jpg'); // = /ThemeA/image3.jpg
Theme::Set('ThemeB'); // ThemeB is Active, it extends ThemeA
theme_url('image1.jpg'); // = /image1.jpg
theme_url('image2.jpg'); // = /ThemeA/image2.jpg
theme_url('image3.jpg'); // = /ThemeB/image3.jpg
All themes fall back to the default laravel folders if a resource is not found on the theme folders.
So for example you can leave your common libraries (jquery/bootstrap ...) in your public
folder and use them from all themes.
No need to duplicate common assets for each theme!
The same behaviour aplies to your views too. When Laravel renders a view it will browse the active Theme's hierarcy until it will find the correct blade file and render it. This can even be a partial view (requested via @include
or @extends
) or a @component
. All themes will fallback to Laravel default folders (eg resources\views
).