function node_preprocess_field__node
Same name in other branches
- 9 core/modules/node/node.module \node_preprocess_field__node()
- 10 core/modules/node/node.module \node_preprocess_field__node()
Implements hook_preprocess_HOOK() for node field templates.
File
-
core/
modules/ node/ node.module, line 412
Code
function node_preprocess_field__node(&$variables) {
// Set a variable 'is_inline' in cases where inline markup is required,
// without any block elements such as <div>.
if ($variables['element']['#is_page_title'] ?? FALSE) {
// Page title is always inline because it will be displayed inside <h1>.
$variables['is_inline'] = TRUE;
}
elseif (in_array($variables['field_name'], [
'created',
'uid',
'title',
], TRUE)) {
// Display created, uid and title fields inline because they will be
// displayed inline by node.html.twig. Skip this if the field
// display is configurable and skipping has been enabled.
// @todo Delete as part of https://www.drupal.org/node/3015623
/** @var \Drupal\node\NodeInterface $node */
$node = $variables['element']['#object'];
$skip_custom_preprocessing = $node->getEntityType()
->get('enable_base_field_custom_preprocess_skipping');
$variables['is_inline'] = !$skip_custom_preprocessing || !$node->getFieldDefinition($variables['field_name'])
->isDisplayConfigurable('view');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.