PHPackages                             heimrichhannot/contao-twig-templates-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. heimrichhannot/contao-twig-templates-bundle

ActiveContao-bundle[Templating &amp; Views](/categories/templating)

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.

2.5.4(2y ago)18.3k↓41.7%[1 issues](https://github.com/heimrichhannot/contao-twig-templates-bundle/issues)[1 PRs](https://github.com/heimrichhannot/contao-twig-templates-bundle/pulls)2LGPL-3.0-or-laterTwigPHP ^7.4 || ^8.0

Since Jan 21Pushed 2y ago4 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-twig-templates-bundle)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-twig-templates-bundle)[ RSS](/packages/heimrichhannot-contao-twig-templates-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (8)Versions (147)Used By (2)

Contao Twig Templates Bundle
============================

[](#contao-twig-templates-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/7b5a281fcd2b3716a4d2ec91c17389d1b34044b2b399c428efd9f6993ad6fec2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865696d7269636868616e6e6f742f636f6e74616f2d747769672d74656d706c617465732d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-twig-templates-bundle)[![Total Downloads](https://camo.githubusercontent.com/2b46212379fb761024ed2b3e48d01f7747ff7e78ea9482a8d11ec1a697eb9a3a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865696d7269636868616e6e6f742f636f6e74616f2d747769672d74656d706c617465732d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-twig-templates-bundle)

This bundle builds on top of [Twig support bundle](https://github.com/heimrichhannot/contao-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
--------

[](#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](https://github.com/contao-bootstrap/templates))
- bundles bootstrap 4 support with optional support for custom form controls

Installation
------------

[](#installation)

Install via composer: `composer require heimrichhannot/contao-twig-templates-bundle` and update your database.

### Additional frontend frameworks

[](#additional-frontend-frameworks)

Available (known) extensions:

- [Bootstrap 3](https://github.com/heimrichhannot/contao-twig-templates-bootstrap3-bundle)
- [Bootstrap 5](https://github.com/heimrichhannot/contao-twig-templates-bootstrap5-bundle)

Usage
-----

[](#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):

1. Frontend framework twig template
2. Core/custom twig template
3. 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

[](#additional-dca-configuration-keys)

These keys can be used in fields eval entry:

KeyDescription`inputPrepend`Content to be added before the input (within input-group-prepend). Overrides other prepended elements.`inputAppend`Content to be added after the input (within input-group-append). Overrides other appended elements.`inline`Input will be displayed horizontal. Only for checkboxes and radio buttons.`groupClass`Classes for outer form group wrapper (default: form-group)`inputGroupClass`Classes for input group wrapper (input-group is always added)### Additional twig functions

[](#additional-twig-functions)

FunctionDescriptiongetCurrentLanguageReturn the current language (`$GLOBALS['TL_LANGUAGE']`)Bundled templates
-----------------

[](#bundled-templates)

### Block templates

[](#block-templates)

TemplateBundledblock\_searchablecoreblock\_unsearchablecore### Content elements

[](#content-elements)

Content Elementbundled corebundled bs4Accordion SinglexxAccordion StartxxAccordion StopxxCodexxDownloadxxDownloadsxxGalleryxxHeadlinexxHTMLxHyperlinkxImagexListxMarkdownxPlayerxSlider StartxSlider StopxTablexTeaserxTextxToplinkxVimeoxxYoutubexx### Member elements

[](#member-elements)

Content Elementbundled corebundled bs4Member defaultxMember groupedx### Gallery

[](#gallery)

Content Elementbundled corebundled bs4Gallery defaultxxBoth version with minimal setting. You definitely need to change those templates to fit your requirements.

### Modules

[](#modules)

Modulesbundled corebundled bs4changesArticlexremoved Gplus ButtonArticle ListxArticle NavxBook NavxBreadcrumbxxChange PasswordxClose AccountxCustom NavxHTMLxLoginxxLost PasswordxMessagexNavigationxPasswordxQuicklinkxQuicknavxRandom ImagexSearchxxSitemapx### Navigation

[](#navigation)

Modulesbundled corebundled bs4Nav DefaultxNav InlinexNav TabsxNav Verticalx### Search

[](#search)

Modulesbundled corebundled bs4Search DefaultxxSearch List GroupxDevelopers
----------

[](#developers)

### Events

[](#events)

To modify template data before parsing or rendering, use the events of [twig support bundle](https://github.com/heimrichhannot/contao-twig-support-bundle#events) 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

[](#add-custom-frontend-frameworks)

1. Create a class which implements `HeimrichHannot\TwigTemplatesBundle\FrontendFramework\FrontendFrameworkInterfacce`

    > Please read the method comments for implementation
2. Register your newly created class as service with `huh.contao_twig_templates.framework` service tag
3. 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:

    ```
