Add theme path global variable and use it to include base views in Thompson / default theme, using the template locator

Description

Background

When a theme base view override is made from the Thompson / default or theme, the original base view is used in all content item templates. This should be done dynamic by getting the path from the template locator.

Requirements

Support including the base view of the current theme, instead of a hardcoded bundle.

Development plan

We would like to combine the namespaced twig paths with a "helper" that gives us the active path:

In this case integrated_active_theme returns a namespaced path, for example:

Things that needs to be changed:
1. Config.yml needs the namespaces, example:

2. Layout/block selector in Integrated needs to look at the namespaces and return the views that can be found.
3. The themes needs to be changed (but this should also be done in the other solutions).
4. The theme manager (perhaps the whole ThemeBundle) can be "deleted" with the recursive path "shizzle".

Technical tasks

None

Deployment actions

DEPRECATED:

  • _theme global -> integrated_active_theme()

Activity

Show:
Ger Jan van den Bosch
March 13, 2018, 2:18 PM

twig:
paths:
'%kernel.project_dir%/vendor/integrated/integrated/src/Bundle/BlockBundle/Resources/views/themes/default': default
'%kernel.project_dir%/vendor/integrated/integrated/src/Bundle/ContentBundle/Resources/views/themes/default': default
'%kernel.project_dir%/vendor/integrated/integrated/src/Bundle/ThemeBundle/Resources/views/themes/default': default
'%kernel.project_dir%/vendor/integrated/integrated/src/Bundle/WebsiteBundle/Resources/views/themes/default': default

'%kernel.project_dir%/vendor/integrated/thompson-theme-bundle/Resources/views/themes/thompson': thompson
'%kernel.project_dir%/vendor/integrated/integrated/src/Bundle/BlockBundle/Resources/views/themes/default': thompson
'%kernel.project_dir%/vendor/integrated/integrated/src/Bundle/ContentBundle/Resources/views/themes/default': thompson
'%kernel.project_dir%/vendor/integrated/integrated/src/Bundle/ThemeBundle/Resources/views/themes/default': thompson
'%kernel.project_dir%/vendor/integrated/integrated/src/Bundle/WebsiteBundle/Resources/views/themes/default': thompson

Jeroen van Leeuwen
March 14, 2018, 12:05 PM

I have looked into this issue, my suggestion is to change the ThemeManager with the Twig/SF namespaces. In order to maintain all the functionality that is needed I have summed up the solutions that we could use:

Fallback
This should be fixed by adding the template directory of the fallback to the namespace. In the standard twig / paths configuration you can not add the same template directory for two namespaces.

This can be fixed with the current Integrated config instead of using the SF / Twig config:

The current fallback option can be removed since the path of the fallback is added to the theme (pithompson).

The extension that loads the integrated_theme config must be changed so the themes are registered as twig namespace, so locating and managing the template files can be handled by SF instead of our own manager

Large config files
First: theme files should be located in the same directory. If they do, the config is small like the example above.

Currently there are written a few CompilerPasses. These passes register theme paths, but I think they can be removed if we place the theme files in one directory.

External bundles that have pieces of templates
I am not sure about this one and if you would want a bundle with a few template files. But maybe for the blocks this is something that is needed when a external bundle has a block with some views for a template. This can be fixed with a compiler pass registering the template directory to the namespace. This is already what is done with the current passes.

Ger Jan van den Bosch
March 23, 2018, 9:30 AM

Solution: {% extends integrated_active_theme("layout.html.twig") %}
Without the namespaced paths

Marijn Otte
March 28, 2018, 8:06 AM

berevetcool! Works very nice.

Ger Jan van den Bosch
March 28, 2018, 10:26 AM

Very nice!

Assignee

Unassigned

Client

Integrated Marijn

Epic Link

Sprint

None

Fix versions

Configure