diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d65d59d..db9d7df 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -583,14 +583,9 @@ function node_theme_suggestions_node(array $variables) { function template_preprocess_node(&$variables) { $variables['view_mode'] = $variables['elements']['#view_mode']; // Provide a distinct $teaser boolean. - $variables['teaser'] = $variables['view_mode'] == 'teaser'; $variables['node'] = $variables['elements']['#node']; /** @var \Drupal\node\NodeInterface $node */ $node = $variables['node']; - $variables['date'] = drupal_render($variables['elements']['created']); - unset($variables['elements']['created']); - $variables['author_name'] = drupal_render($variables['elements']['uid']); - unset($variables['elements']['uid']); $variables['url'] = $node->url('canonical', array( 'language' => $node->language(), @@ -611,9 +606,13 @@ function template_preprocess_node(&$variables) { // Display post information only on certain node types. $node_type = $node->type->entity; // Used by RDF to add attributes around the author and date submitted. - $variables['author_attributes'] = new Attribute(); $variables['display_submitted'] = $node_type->displaySubmitted(); if ($variables['display_submitted']) { + $variables['author_attributes'] = new Attribute(); + $variables['date'] = drupal_render($variables['elements']['created']); + unset($variables['elements']['created']); + $variables['author_name'] = drupal_render($variables['elements']['uid']); + unset($variables['elements']['uid']); if (theme_get_setting('features.node_user_picture')) { // To change user picture settings (e.g. image style), edit the 'compact' // view mode on the User entity. Note that the 'compact' view mode might diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index c08ab7c..5080da2 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -16,13 +16,16 @@ * or print a subset such as {{ content.field_example }}. Use * {{ content|without('field_example') }} to temporarily suppress the printing * of a given child element. - * - author_picture: The node author user entity, rendered using the "compact" - * view mode. * - metadata: Metadata for this node. - * - date: Themed creation date field. - * - author_name: Themed author name field. * - url: Direct URL of the current node. * - display_submitted: Whether submission information should be displayed. + * If display_submitted is set, additional variables are prepared: + * - author_picture: The node author user entity, rendered using the "compact" + * view mode.. + * - date: Themed creation date field. + * - author_name: Themed author name field. + * - author_attributes: Same as attributes, except applied to the author of + * the node that appears in the template. * - attributes: HTML attributes for the containing element. * The attributes.class element may contain one or more of the following * classes: @@ -43,17 +46,12 @@ * tag that appears in the template. * - content_attributes: Same as attributes, except applied to the main * content tag that appears in the template. - * - author_attributes: Same as attributes, except applied to the author of - * the node tag that appears in the template. * - title_prefix: Additional output populated by modules, intended to be * displayed in front of the main title tag that appears in the template. * - title_suffix: Additional output populated by modules, intended to be * displayed after the main title tag that appears in the template. * - view_mode: View mode; for example, "teaser" or "full". - * - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'. * - page: Flag for the full page state. Will be true if view_mode is 'full'. - * - readmore: Flag for more state. Will be true if the teaser content of the - * node cannot hold the main body content. * - is_front: Flag for front. Will be true when presented on the front page. * - logged_in: Flag for authenticated user status. Will be true when the * current user is a logged-in member.