Field Formatter Template
Description
--------------------------
Field Formatter Template (FFT) allow you can easy create formatter template for any field.
Installation
--------------------------
1. Copy the entire fft directory the Drupal sites/all/modules for Drupal 7 and modules/contrib for Drupal 8
directory or use Drush with drush dl fft.
2. Login as an administrator. Enable the module on the Modules page.
Usage Drupal 8
--------------------------
- Create your template, default formatter template store in folder
'sites/all/formatter', you can change this folder at 'admin/config/content/fft'.
Formatter template create as normal twig template, example you create inline tags
template, create file with name 'fft-inline-tags.html.twig' in folder
'sites/all/formatter' open file and type:
{#Template Name: Inline Tags#}
{#Settings:
delimiter = >>
#}
{% set values = [] %}
{% for item in data %}
{% set term = link(item.name.value, 'internal:/taxonomy/term/' ~ item.tid.value)|render %}
{% set values = values|merge([term]) %}
{% endfor %}
<div>{{ values | join(' ' ~ settings.delimiter ~ ' ') | raw }}</div>
Now open "Manage Display" of a content type, chose any field and chose
"Formatter Template" you can config and select "Inline Tags". Your field
formatter will display with 'fft-inline-tags.html.twig'. Variables you can use in
template is data and entity
- data: stored all data of selected field.
- entity: attached entity of field.
- settings: settings extras for template.
Clear cache after settings to make effect.
Note for Drupal 8:
Twig template for field must start with prefix fft
Example:
fft-inline-tags.html.twig
fft-flexslider.html.twig
Usage Drupal 7
--------------------------
- Create your template, default formatter template store in folder
'sites/all/formatter', you can change this folder at 'admin/config/content/fft'.
Formatter template create as normal tpl template, example you create inline tags template, create file with name 'fft-inline-tags.tpl.php' in folder 'sites/all/formatter'
open file and type:
<?php
/*Template Name: Inline Tags*/
// dpm($data);
$tags = array();
foreach ($data as $key => $item) {
$tags[] = l($item['name'], "taxonomy/term/" . $item['tid']);
}
print implode(" | ", $tags);
?>
Now open "Manage Display" of a content type, chose any field and chose
"Formatter Template" you can config and select "Inline Tags". Your field
formatter will display with 'fft-inline-tags.tpl.php'. Variables you can use in
template is $data and $entity
- $data: stored all data of selected field.
- $entity: attached entity of field.
- $settings: settings extras for template.
Example templates
--------------------------
Inline Taxonomy Term: display inline taxonomy term for Term reference field.
Slideshow FlexSlider: display image as slideshow with FlexSlider.
Thumbnail Slideshow FlexSlider: display image as thumbnail slideshow with FlexSlider.
CarouFredSel: display slideshow with CarouFredSel.
Owl Carousel: Slideshow with Owl Carousel.
Video
--------------------------
Video intro how to use FFT: https://www.youtube.com/watch?v=kF-Sa86VEtM
Video create FlexSlider formatter with FFT: https://www.youtube.com/watch?v=Yn2373Qftfg
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | Release date | |
|---|---|---|---|---|
| 3.0.1 | Stable | 9–11 | Sep 23, 2024 | |
| 3.0.0 | Stable | Sep 12, 2023 | ||
| 3.0.1-beta1 | Pre-release | Jun 20, 2023 |