You are here

function brainstorm_theme_preprocess_node in Brainstorm profile 8

Implements hook_preprocess_HOOK() for node.html.twig.

File

theme/brainstorm_theme/brainstorm_theme.theme, line 28
Process theme data.

Code

function brainstorm_theme_preprocess_node(&$variables) {

  // Remove the "Add new comment" link on teasers or when the comment form is
  // displayed on the page.
  if ($variables['node']
    ->getType() == 'blog') {
    if ($variables['content']['field_blog_image_fuul']) {
      $variables['field_blog_image_fuul'] = $variables['content']['field_blog_image_fuul'];
      unset($variables['content']['field_blog_image_fuul']);
    }
    $variables['comment_count'] = $variables['node']
      ->get('field_comment_blog')->comment_count ?: 0;
    if (\Drupal::service('module_handler')
      ->moduleExists('addtoany')) {
      $block_service = \Drupal::service('plugin.manager.block');
      $addtoany_block = $block_service
        ->createInstance('addtoany_block', []);
      $variables['addtoany'] = $addtoany_block
        ->build();
    }
  }
  if ($variables['node']
    ->getType() == 'portfolio') {
    if ($variables['content']['field_portfolio_image']) {
      $variables['field_portfolio_image'] = $variables['content']['field_portfolio_image'];
      unset($variables['content']['field_portfolio_image']);
    }
  }
  if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) {
    unset($variables['content']['links']['comment']['#links']['comment-add']);
  }
}