Skip to content

Commit

Permalink
Issue #2536:Ffix display of submitted info for node in block.
Browse files Browse the repository at this point in the history
  • Loading branch information
herbdool authored and quicksketch committed May 23, 2019
1 parent e92b579 commit 363c6ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 1 addition & 3 deletions core/modules/node/node.block.inc
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ class NodeBlock extends Block {
}

// Add 'submitted by' settings.
if (!empty($this->settings['display_submitted'])) {
$content['#display_submitted'] = TRUE;
}
$content['#display_submitted'] = !empty($this->settings['display_submitted']);

// Add theme hook suggestion.
$content['#theme'] = 'node__block_' . $this->settings['nid'];
Expand Down
13 changes: 6 additions & 7 deletions core/modules/node/node.theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ function template_preprocess_node(&$variables) {
$variables['node_url'] = url($uri['path'], $uri['options']);
$variables['title'] = check_plain($node->title);
$variables['page'] = ($variables['view_mode'] == 'full' && node_is_page($node)) || (!empty($node->in_preview));
$variables['block'] = $variables['view_mode'] == 'block';

// Flatten the node entity's member fields.
$variables = array_merge((array) $node, $variables);
Expand All @@ -226,8 +225,13 @@ function template_preprocess_node(&$variables) {

// Display post information only on certain node types.
$node_type = node_type_get_type($node->type);

$variables['display_submitted'] = FALSE;
$variables['submitted'] = '';
$variables['user_picture'] = '';

if ($node_type->settings['node_submitted']) {
if (!$variables['block'] || ($variables['block'] && !empty($variables['elements']['#display_submitted']))) {
if (!isset($variables['elements']['#display_submitted']) || $variables['elements']['#display_submitted'] == TRUE) {
$variables['display_submitted'] = TRUE;
$variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date']));
$variables['user_picture'] = '';
Expand All @@ -236,11 +240,6 @@ function template_preprocess_node(&$variables) {
}
}
}
else {
$variables['display_submitted'] = FALSE;
$variables['submitted'] = '';
$variables['user_picture'] = '';
}

// Add article ARIA role.
$variables['attributes']['role'] = 'article';
Expand Down

1 comment on commit 363c6ba

@backdrop-ci
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.