vuukle-2.0.0/vuukle.module

vuukle.module
<?php

/**
 * @file
 * Contains vuukle.module..
 */

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;

/**
 * Implements hook_help().
 */
function vuukle_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the vuukle module.
    case 'help.page.vuukle':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Integrate the vuukle comment system for the content type nodes.') . '</p>';
      return $output;
  }
}

/**
 * Implements hook_node_view().
 */
function vuukle_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
  $config = \Drupal::service('config.factory')->getEditable('vuukleconfig.setting');
  $content_type = $config->get('vuukle_content_type');
  $rating_text = $config->get('rating_text');
  $comment_text_0 = $config->get('comment_text_0');
  $comment_text_1 = $config->get('comment_text_1');
  $comment_text_multi = $config->get('comment_text_multi');
  $ga_code = $config->get('ga_code');
  $vuukle_api_key = $config->get('vuukle_api_key');
  $vuukle_col_code = $config->get('vuukle_col_code');
  $stories_title = $config->get('stories_title');
  if (in_array($node->getType(), $content_type, TRUE)) {
    $build['#attached']['drupalSettings']['vuukle']['rating_text'] = $rating_text;
    $build['#attached']['drupalSettings']['vuukle']['comment_text_0'] = $comment_text_0;
    $build['#attached']['drupalSettings']['vuukle']['comment_text_1'] = $comment_text_1;
    $build['#attached']['drupalSettings']['vuukle']['comment_text_multi'] = $comment_text_multi;
    $build['#attached']['drupalSettings']['vuukle']['ga_code'] = $ga_code;
    $build['#attached']['drupalSettings']['vuukle']['vuukle_api_key'] = $vuukle_api_key;
    $build['#attached']['drupalSettings']['vuukle']['vuukle_col_code'] = $vuukle_col_code;
    $build['#attached']['drupalSettings']['vuukle']['stories_title'] = $stories_title;
    $build['#attached']['drupalSettings']['vuukle']['node_id'] = $node->Id();
    $build['#attached']['drupalSettings']['vuukle']['node_title'] = $node->get('title')->value;
    $build['#attached']['library'][] = 'vuukle/vuukle.intjs';
    $build['vuukle_section'] = [
      '#markup' => '<div class="vuukle-powerbar" style="margin-top:20px;"><br/> </div> <div id="vuukle_div" style = "margin:20px 0"></div><br/>',
      '#weight' => 100,
    ];
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc