uber_publisher_in_pictures-7.0.0/uber_publisher_in_pictures.module

uber_publisher_in_pictures.module
<?php

/**
 * @file
 * Contains uber_publisher_in_pictures.module.
 */

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_theme().
 */
function uber_publisher_in_pictures_theme() {
  return [
    'in_pictures_tabs' => [
      'variables' => [
        'list' => t('List'),
        'slider' => t('Slider'),
      ],
      'template' => 'in-pictures-tabs',
    ],
  ];
}

/**
 * Implements hook_page_attachments().
 */
function uber_publisher_in_pictures_page_attachments(array &$attachments) {
  $attachments['#attached']['library'][] = 'uber_publisher_in_pictures/general-scripts';
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function uber_publisher_in_pictures_form_node_in_pictures_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['ds_switch_view_mode']['ds_switch']['#options'] = [];
  $form['ds_switch_view_mode']['ds_switch']['#options']['full'] = t('Big picture');
  $form['ds_switch_view_mode']['ds_switch']['#options']['grid_gallery'] = t('Grid gallery');
  $form['ds_switch_view_mode']['ds_switch']['#default_value'] = 'full';
  $form['actions']['preview']['#access'] = FALSE;
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function uber_publisher_in_pictures_form_node_in_pictures_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['ds_switch_view_mode']['ds_switch']['#options'] = [];
  $form['ds_switch_view_mode']['ds_switch']['#options']['full'] = t('Big picture');
  $form['ds_switch_view_mode']['ds_switch']['#options']['grid_gallery'] = t('Grid gallery');
}

/**
 * Implements hook_views_pre_view().
 */
function uber_publisher_in_pictures_views_pre_view($view, $display_id, &$args) {
  if ($view->id() == 'in_picture' && ($display_id == 'in_pictures_slider_style' || $display_id == 'in_pictures_big_picture_style'
      || $display_id == "in_pictures_grid")) {

    $route = \Drupal::routeMatch();

    if ($route->getRouteName() == 'entity.node.preview') {
      $uuid = $route->getParameter('node_preview')->uuid->value;
      $entity = \Drupal::service('entity.repository')->loadEntityByUuid('node', $uuid);
      $args[0] = $entity->id();
    }
  }
}

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

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