Creates a simple theming using a Child Theme and a Base Theme., (*1)
If the template name exists in the child, the child bundle template is used., (*2)
Else, The base theme will be used., (*3)
The Base theme is set in the service.yml while the Child is passed during the service call., (*4)
src
|-BaseThemeBundle/Resources/views/**.html.twig
|-ChildThemeBundle/Resources/views/**.html.twig
A Theme is simply a bundle with views., (*5)
Installation
In composer.json
"require": {
"djaney/theming-bundle": "dev-master"
}
Usage
Register the service
Second argument is the name of the base theme, (*6)
services:
theme:
class: Djaney\ThemingBundle\ThemeSelector\ThemeSelectorService
arguments: [ "@twig" , BaseThemeBundle ]
Use in Controller
second argument is the theme name. Set as NULL to use base theme.
return $this->get('theme')->template('Default/index.html.twig', 'ChildThemeBundle', $data);