heimrichhannot / contao-twig-templates-bundle
This bundle ships core contao templates as twig templates and additional templates using the latest Bootstrap framework's CSS for the Contao CMS.
Installs: 7 220
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 0
Open Issues: 2
Language:Twig
Type:contao-bundle
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.9
- heimrichhannot/contao-twig-support-bundle: ^0.2.1||^1.0
- heimrichhannot/contao-utils-bundle: ^2.222
- symfony/event-dispatcher: ^4.4||^5.4
- symfony/event-dispatcher-contracts: ^1||^2||^3
- symfony/polyfill-php80: ^1.26
- symfony/translation: ^4.4||^5.4
- symfony/translation-contracts: ^1.1.6||^2||^3
- dev-master
- 2.5.4
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.10
- 2.4.9
- 2.4.8
- 2.4.7
- 2.4.6
- 2.4.5
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0-beta11
- 2.0.0-beta10
- 2.0.0-beta9
- 2.0.0-beta8
- 2.0.0-beta7
- 2.0.0-beta6
- 2.0.0-beta5
- 2.0.0-beta4
- 2.0.0-beta3
- 2.0.0-beta2
- 2.0.0-beta1
- v1.x-dev
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.47
- 1.1.46
- 1.1.45
- 1.1.44
- 1.1.43
- 1.1.41
- 1.1.40
- 1.1.39
- 1.1.38
- 1.1.37
- 1.1.36
- 1.1.35
- 1.1.34
- 1.1.33
- 1.1.32
- 1.1.31
- 1.1.30
- 1.1.29
- 1.1.28
- 1.1.27
- 1.1.26
- 1.1.25
- 1.1.24
- 1.1.23
- 1.1.22
- 1.1.21
- 1.1.20
- 1.1.19
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.2
- 1.0.1
- 1.0.0
- 0.8.1
- 0.8.0
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.1
- 0.5.0
- 0.4.6
- 0.4.5
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.0
- dev-contao5
- dev-feature/bootstrap5
This package is auto-updated.
Last update: 2024-11-04 10:51:34 UTC
README
This bundle builds on top of Twig support bundle and replaces the most core templates with twig templates. In addition, it comes with an expandable frontend framework architecture that allows to select a frontend framework in your layout and automatically use customized templates instead of the core templates.
Features
- replaces various core templates with twig templates
- expandable frontend framework architecture to easily add your frontend framework without changing all templates in contao backend or override core templates
- automatic usage of templates prepared for frontend frameworks, if set in settings (inspired by contao-bootstrap/templates)
- bundles bootstrap 4 support with optional support for custom form controls
Installation
Install via composer: composer require heimrichhannot/contao-twig-templates-bundle
and update your database.
Additional frontend frameworks
Available (known) extensions:
Usage
It's as simple as that: Check 'Use twig templates' in your page layout configuration. If your want to use a frontend framework like bootstrap, select the corresponding option in the 'Use framework' select. This way the automapping takes place and according to the current content element or module, the correct template is used.
Automapping order (check if template exists, else use the next one):
- Frontend framework twig template
- Core/custom twig template
- Default/Custom (contao html5) template
If you don't want to use automapping you can also assign the template you want in the ordinary way by selecting it in the customTpl
field of your module or content element.
Additional dca configuration keys
These keys can be used in fields eval entry:
Additional twig functions
Bundled templates
Block templates
Content elements
Member elements
Gallery
Both version with minimal setting. You definitely need to change those templates to fit your requirements.
Modules
Navigation
Search
Developers
Events
To modify template data before parsing or rendering, use the events of twig support bundle with a priority lower than 100 (0 is default, so you don't need to set this value in most cases).
Add custom frontend frameworks
-
Create a class which implements
HeimrichHannot\TwigTemplatesBundle\FrontendFramework\FrontendFrameworkInterfacce
Please read the method comments for implementation
-
Register your newly created class as service with
huh.contao_twig_templates.framework
service tag -
For each template, you want to replace, create an html5 template (where filename suffix is the same as the identifier set in the class, example
form_checkbox_bs4.html5
) and call the template factory. Typical this code can be used without any adjustment:<?= \Contao\System::getContainer()->get('huh.utils.template')->renderTwigTemplate($this->getName(), $this->getData()); ?>
-
If your want to set template specific options (for example bootstrap 4 custom control support) you can use
$template::addSupport()
. Example:<?php $template = \Contao\System::getContainer()->get('huh.twig.template.factory')->createInstance($this); $template->addSupport('custom-forms', true); echo $template->render();
-
-
Create a twig template with the same name as the html5 template (e.g.
form_checkbox_bs4.html.twig
). This is the place where your custom template code will live. All template variable are given as twig variables. Please see bundle templates for some examples.
Template variables
Additional template variables