heimrichhannot/contao-twig-templates-bundle
Composer 安装命令:
composer require 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.
README 文档
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:
| Key | Description |
|---|---|
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
| Function | Description |
|---|---|
| getCurrentLanguage | Return the current language ($GLOBALS['TL_LANGUAGE']) |
Bundled templates
Block templates
| Template | Bundled |
|---|---|
| block_searchable | core |
| block_unsearchable | core |
Content elements
| Content Element | bundled core | bundled bs4 |
|---|---|---|
| Accordion Single | x | x |
| Accordion Start | x | x |
| Accordion Stop | x | x |
| Code | x | x |
| Download | x | x |
| Downloads | x | x |
| Gallery | x | x |
| Headline | x | x |
| HTML | x | |
| Hyperlink | x | |
| Image | x | |
| List | x | |
| Markdown | x | |
| Player | x | |
| Slider Start | x | |
| Slider Stop | x | |
| Table | x | |
| Teaser | x | |
| Text | x | |
| Toplink | x | |
| Vimeo | x | x |
| Youtube | x | x |
Member elements
| Content Element | bundled core | bundled bs4 |
|---|---|---|
| Member default | x | |
| Member grouped | x |
Gallery
| Content Element | bundled core | bundled bs4 |
|---|---|---|
| Gallery default | x | x |
Both version with minimal setting. You definitely need to change those templates to fit your requirements.
Modules
| Modules | bundled core | bundled bs4 | changes |
|---|---|---|---|
| Article | x | removed Gplus Button | |
| Article List | x | ||
| Article Nav | x | ||
| Book Nav | x | ||
| Breadcrumb | x | x | |
| Change Password | x | ||
| Close Account | x | ||
| Custom Nav | x | ||
| HTML | x | ||
| Login | x | x | |
| Lost Password | x | ||
| Message | x | ||
| Navigation | x | ||
| Password | x | ||
| Quicklink | x | ||
| Quicknav | x | ||
| Random Image | x | ||
| Search | x | x | |
| Sitemap | x |
Navigation
| Modules | bundled core | bundled bs4 |
|---|---|---|
| Nav Default | x | |
| Nav Inline | x | |
| Nav Tabs | x | |
| Nav Vertical | x |
Search
| Modules | bundled core | bundled bs4 |
|---|---|---|
| Search Default | x | x |
| Search List Group | x |
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\FrontendFrameworkInterfaccePlease read the method comments for implementation
-
Register your newly created class as service with
huh.contao_twig_templates.frameworkservice 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
| Name | Type | Default | Description |
|---|---|---|---|
| groupClass | string | form-group | The outer form group class |
| inputGroupClass | string | form-group | The input group class |
| _entity | object | - | The context entity object (e.g. \Contao\FormTextField) |
heimrichhannot/contao-twig-templates-bundle 适用场景与选型建议
heimrichhannot/contao-twig-templates-bundle 是一款 基于 Twig 开发的 Composer 扩展包,目前已累计 8.35k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 heimrichhannot/contao-twig-templates-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 heimrichhannot/contao-twig-templates-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8.35k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 19
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2018-12-18