{"id":20961712,"url":"https://github.com/heimrichhannot/contao-twig-templates-bundle","last_synced_at":"2026-04-06T00:03:52.286Z","repository":{"id":48157428,"uuid":"156194313","full_name":"heimrichhannot/contao-twig-templates-bundle","owner":"heimrichhannot","description":"Replace contao templates with twig templates.","archived":false,"fork":false,"pushed_at":"2024-04-04T09:35:12.000Z","size":400,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-20T08:18:00.341Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Twig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heimrichhannot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-05T09:46:26.000Z","updated_at":"2022-12-14T22:54:38.000Z","dependencies_parsed_at":"2022-09-22T18:51:16.204Z","dependency_job_id":null,"html_url":"https://github.com/heimrichhannot/contao-twig-templates-bundle","commit_stats":null,"previous_names":[],"tags_count":143,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fcontao-twig-templates-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fcontao-twig-templates-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fcontao-twig-templates-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimrichhannot%2Fcontao-twig-templates-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heimrichhannot","download_url":"https://codeload.github.com/heimrichhannot/contao-twig-templates-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243358306,"owners_count":20277995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T02:15:51.682Z","updated_at":"2025-12-30T00:39:33.166Z","avatar_url":"https://github.com/heimrichhannot.png","language":"Twig","readme":"# Contao Twig Templates Bundle\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/heimrichhannot/contao-twig-templates-bundle.svg)](https://packagist.org/packages/heimrichhannot/contao-twig-templates-bundle)\n[![Total Downloads](https://img.shields.io/packagist/dt/heimrichhannot/contao-twig-templates-bundle.svg)](https://packagist.org/packages/heimrichhannot/contao-twig-templates-bundle)\n\nThis 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.\n \n## Features\n- replaces various core templates with twig templates\n- expandable frontend framework architecture to easily add your frontend framework without changing all templates in contao backend or override core templates\n- automatic usage of templates prepared for frontend frameworks, if set in settings (inspired by [contao-bootstrap/templates](https://github.com/contao-bootstrap/templates))\n- bundles bootstrap 4 support with optional support for custom form controls\n\n## Installation\n\nInstall via composer: `composer require heimrichhannot/contao-twig-templates-bundle` and update your database.\n\n### Additional frontend frameworks\n\nAvailable (known) extensions:\n* [Bootstrap 3](https://github.com/heimrichhannot/contao-twig-templates-bootstrap3-bundle)\n* [Bootstrap 5](https://github.com/heimrichhannot/contao-twig-templates-bootstrap5-bundle)\n\n## Usage\n\nIt'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.\n\nAutomapping order (check if template exists, else use the next one):\n1. Frontend framework twig template\n1. Core/custom twig template\n1. Default/Custom (contao html5) template\n\nIf 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.\n\n### Additional dca configuration keys\n\nThese keys can be used in fields eval entry:\n\nKey            | Description\n-------------- |-----------\n`inputPrepend` | Content to be added before the input (within input-group-prepend). Overrides other prepended elements.\n`inputAppend`  | Content to be added after the input (within input-group-append). Overrides other appended elements.\n`inline`       | Input will be displayed horizontal. Only for checkboxes and radio buttons. \n`groupClass`   | Classes for outer form group wrapper (default: form-group)\n`inputGroupClass`   | Classes for input group wrapper (input-group is always added)\n\n### Additional twig functions\n\nFunction | Description\n-------- | -----------\ngetCurrentLanguage | Return the current language (`$GLOBALS['TL_LANGUAGE']`)\n\n## Bundled templates\n\n### Block templates\n\nTemplate | Bundled\n-------- | -------\nblock_searchable | core\nblock_unsearchable | core\n\n### Content elements\n\nContent Element  | bundled core | bundled bs4\n---------------- | :----------: | :----------:\nAccordion Single |       x      |       x     \nAccordion Start  |       x      |       x    \nAccordion Stop   |       x      |       x    \nCode             |       x      |       x    \nDownload         |       x      |       x    \nDownloads        |       x      |       x    \nGallery          |       x      |       x    \nHeadline         |       x      |       x    \nHTML             |       x      |           \nHyperlink        |       x      |           \nImage            |       x      |           \nList             |       x      |           \nMarkdown         |       x      |           \nPlayer           |       x      |           \nSlider Start     |       x      |           \nSlider Stop      |       x      |           \nTable            |       x      |           \nTeaser           |       x      |            \nText             |       x      |           \nToplink          |       x      |           \nVimeo            |       x      |       x    \nYoutube          |       x      |       x   \n\n### Member elements\n\nContent Element  | bundled core | bundled bs4\n---------------- | :----------: | :----------:\nMember default   |       x      |            \nMember grouped   |       x      |     \n\n### Gallery\n\nContent Element  | bundled core | bundled bs4\n---------------- | :----------: | :----------:\nGallery default  |       x      |       x\n\nBoth version with minimal setting. You definitely need to change those templates to fit your requirements.\n\n### Modules\n\nModules          | bundled core | bundled bs4  | changes\n---------------- | :----------: | :----------: | :----------:\nArticle          |       x      |              | removed Gplus Button\nArticle List     |       x      |              | \nArticle Nav      |       x      |              | \nBook Nav         |       x      |              | \nBreadcrumb       |       x      |       x      | \nChange Password  |       x      |              | \nClose Account    |       x      |              | \nCustom Nav       |       x      |              | \nHTML             |       x      |              | \nLogin            |       x      |       x      | \nLost Password    |       x      |              | \nMessage          |       x      |              | \nNavigation       |       x      |              | \nPassword         |       x      |              | \nQuicklink        |       x      |              | \nQuicknav         |       x      |              | \nRandom Image     |       x      |              | \nSearch           |       x      |       x      | \nSitemap          |       x      |              | \n\n### Navigation\n\nModules          | bundled core | bundled bs4  | \n---------------- | :----------: | :----------: | \nNav Default      |       x      |              | \nNav Inline       |              |       x      | \nNav Tabs         |              |       x      | \nNav Vertical     |              |       x      | \n\n### Search\n\nModules          | bundled core | bundled bs4  | \n---------------- | :----------: | :----------: | \nSearch Default   |       x      |       x      | \nSearch List Group|              |       x      | \n\n## Developers\n\n### Events\n\nTo 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).\n\n### Add custom frontend frameworks\n\n1. Create a class which implements `HeimrichHannot\\TwigTemplatesBundle\\FrontendFramework\\FrontendFrameworkInterfacce`\n    \u003e Please read the method comments for implementation\n1. Register your newly created class as service with `huh.contao_twig_templates.framework` service tag\n1. 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: \n\n    ```php\n    \u003c?= \\Contao\\System::getContainer()-\u003eget('huh.utils.template')-\u003erenderTwigTemplate($this-\u003egetName(), $this-\u003egetData()); ?\u003e\n    ```\n    * If your want to set template specific options (for example bootstrap 4 custom control support) you can use `$template::addSupport()`. Example:\n    \n        ```\n         \u003c?php \n        $template = \\Contao\\System::getContainer()-\u003eget('huh.twig.template.factory')-\u003ecreateInstance($this);\n        $template-\u003eaddSupport('custom-forms', true);\n        echo $template-\u003erender();\n        ```\n\n1. 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.\n\n### Template variables\n\nAdditional template variables\n\nName            | Type   | Default    | Description\n--------------- | ------ | ---------- | -----------\ngroupClass      | string | form-group | The outer form group class\ninputGroupClass | string | form-group | The input group class\n_entity | object | - | The context entity object (e.g. \\Contao\\FormTextField)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimrichhannot%2Fcontao-twig-templates-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheimrichhannot%2Fcontao-twig-templates-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimrichhannot%2Fcontao-twig-templates-bundle/lists"}