ws_small_y-1.0.x-dev/modules/ws_small_y_staff/ws_small_y_staff.module

modules/ws_small_y_staff/ws_small_y_staff.module
<?php

/**
 * @file
 * Primary module hooks for YMCA Website Services - Small Y Staff Members module.
 */

/**
 * Implements hook_theme().
 */
function ws_small_y_staff_theme($existing, $type, $theme, $path) {
  return [
    'block__lb_staff_members' => [
      'base hook' => 'block',
    ]
  ];
}

/**
 * Implements hook_preprocess_block().
 */
function ws_small_y_staff_preprocess_block__lb_staff_members(&$variables) {
  $variables['block_content'] = $variables['elements']['content']['#block_content'];
  _ws_small_y_staff_get_additional_column_classes($variables);
}

/**
 * Get additional classes from columns value.
 *
 * @param array $variables
 *   A render array for the block.
 *
 * @return void
 */
function _ws_small_y_staff_get_additional_column_classes(&$variables): void {
  $columns = (int) $variables['block_content']->field_columns->value ?? 1;
  $variables['row_class'] = "row-cols-lg-{$columns}";
  if ($columns >= 3) {
    $variables['row_class'] .= " row-cols-md-2";
  }
  else {
    $variables['row_class'] .= " row-cols-md-{$columns}";
  }
}

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

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