age_field_formatter.module in Age Field Formatter 3.0.x
Same filename and directory in other branches
Field hooks to implement a date field formatter to calculate and display the age.
File
age_field_formatter.moduleView source
<?php
/**
* @file
* Field hooks to implement a date field formatter to calculate and display the age.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function age_field_formatter_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the age_field_formatter module.
case 'help.page.age_field_formatter':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Age Field Formatter calculates and formats the display of a date field to display the age. It also offers the option to display both the date with the age, along with the possibility to add the “years” suffix to the age value.') . '</p>';
$output .= '<p>' . t('This is a date field formatter. You can access the field format in the content type Manage display tab.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function age_field_formatter_theme() {
return [
'age_field_formatter' => [
'template' => 'age_field_formatter',
'render element' => 'children',
],
];
}
/**
* Implements hook_formatter_page_attachments().
*/
function age_field_formatter_page_attachments(array &$attachments) {
$attachments['#attached']['library'][] = 'age_field_formatter/age-field-formatter';
}
Functions
Name | Description |
---|---|
age_field_formatter_help | Implements hook_help(). |
age_field_formatter_page_attachments | Implements hook_formatter_page_attachments(). |
age_field_formatter_theme | Implements hook_theme(). |