You are here

function opigno_forum_preprocess_node in Opigno forum 8

Same name and namespace in other branches
  1. 3.x opigno_forum.module \opigno_forum_preprocess_node()

Implements hook_preprocess_HOOK().

File

./opigno_forum.module, line 229
Contains opigno_forum.module.

Code

function opigno_forum_preprocess_node(&$variables) {
  if ($variables['node']
    ->getType() == 'forum' && $variables['view_mode'] == 'full') {
    $node = $variables['node'];
    $topics_list_link = $node->taxonomy_forums
      ->getValue();
    if (!empty($topics_list_link)) {
      $variables['topics_list_link'] = Link::createFromRoute(t('To the topics list'), 'forum.page', [
        'taxonomy_term' => $topics_list_link['0']['target_id'],
      ], [
        'attributes' => [
          'class' => 'btn btn-success color-white text-uppercase btn-back',
        ],
      ]);
    }
  }
}