You are here

varbase_core.module in Varbase Core 8.5

File

varbase_core.module
View source
<?php

/**
 * @file
 * Contains varbase_core.module.
 */

// To have all varbase core general and global tokens.
\Drupal::moduleHandler()
  ->loadInclude('varbase_core', 'inc', 'varbase_core.tokens');

/**
 * Implements hook_FORM_ID_form_alter.
 */
function varbase_core_form_node_form_alter(&$form, $form_state) {

  // Override node form sidebar order.
  if (isset($form['author'])) {
    $form['author']['#weight'] = -6;
  }
  if (isset($form['field_comments'])) {
    $form['field_comments']['widget'][0]['#weight'] = -5;
  }
  if (isset($form['path_settings'])) {
    $form['path_settings']['#weight'] = -4;
  }
  if (isset($form['field_meta_tags'])) {
    $form['field_meta_tags']['widget'][0]['#weight'] = -3;
  }
  if (isset($form['simple_sitemap'])) {
    $form['simple_sitemap']['#weight'] = -2;
  }
  if (isset($form['ds_switch_view_mode'])) {
    $form['ds_switch_view_mode']['#weight'] = 101;
  }
}

/**
 * Implements hook_template_preprocess_default_variables_alter().
 */
function varbase_core_template_preprocess_default_variables_alter(&$variables) {
  $user_settings_config = \Drupal::config('user.settings');
  $variables['user_settings_register_admin_only'] = $user_settings_config
    ->get('register') == 'admin_only' ? 1 : 0;
}