bootstrap_theme_toggler-2.0.0/bootstrap_theme_toggler.module

bootstrap_theme_toggler.module
<?php


/**
 * Implements hook_page_attachements()
 * 
 * Used to add the color theme toggler javascript to every page.
 * Even pages that do not have the toggler button must have this script,
 * otherwise the theme will not update to the current selection.
 */
function bootstrap_theme_toggler_page_attachments(array &$attachments) {
  $attachments['#attached']['library'][] = 'bootstrap_theme_toggler/global-styling';
}


/**
 * Implements hook_theme()
 * 
 * Registers the 'block--toggler.html.twig' template,
 * and variables to receive from configuration.
 */
function bootstrap_theme_toggler_theme($existing, $type, $theme, $path) {

  return [
    'block__toggler' => [
      // 'template' => 'block--toggler',
      // 'path' => \Drupal::service('extension.list.module')->
      //           getPath('main_sections').'/templates/plugins',
      'variables' => [
        'basePath' => \Drupal::service('extension.list.module')->getPath('bootstrap_theme_toggler'),
        'toggler_label' => null,
        'show_toggler_label' => null,
        'show_option_labels' => null,
        'show_icons' => null,
        'show_checkmark' => null,
        'cusomt_only' => null,
        'theme_modes' => null,
      ],
    ],
  ];
  
}


/**
 * Implements hook_help().
 */
function bootstrap_theme_toggler_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) {

  switch ($route_name) {
    case 'help.page.bootstrap_theme_toggler':
      $output = '<h3>' . t('About') . '</h3>';
      $output .= "<p>" . t("The Bootstrap Theme Toggler is a drop-down, theme mode selector, that facilitates theme switching between native bootstrap color modes, `light`, `dark`, and `auto`. This feature requires the bootstrap library, version 5.3, or later, and expects the site theme is compatible with it. If utlizing a SASS based theme, this module will also faclitate customizing the default, light, and dark theme palettes, as well as creating addional, custom themes.
      <br><br>
      The toggler can be placed into any region, however it should only be placed once on a site.
      <br><br>
      The Bootstrap Barrio 5 Theme & its Bootstrap 5 - SASS Starter Kit, are the predominant Drupal, base themes utlizing bootstrap 5, as such, this module has been delevoped, with sites  using those themes, in mind. However, it is expected this toggler will also be compatible with any site implmenting Bootstrap 5.3 based color mode themes. </p>") . 
      t("<a href=':Module Documentation'>Bootstrap Theme Toggler Module Documentation</a>", [':Module Documentation' => 'https://www.drupal.org/docs/extending-drupal/contributed-modules/contributed-module-documentation/bootstrap-theme-toggler-block']);
      $output .= '<h3>' . t('Requirements & Recommended') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Requirement') . '</dt>';
      $output .= '<dd>' . t("<a href= ':Bootstrap Library'>Bootstrap Library ver. 5.3</a> or later, with built in color mode support.", [':Bootstrap Library' => 'https://getbootstrap.com/docs/5.3/customize/color-modes/']) . '</dd>';
      $output .= '<dd>' . t("<a href= ':Popper Library'>Popper.js</a> (included in Drupal Core pre-Drupal 10, included in '..web/vendor/twbs' bootstrap version installed with Bootstrap 5 Barrio Theme. Also included in Barrio SASS sub-theme, but must be added to the 'sub_theme.libraries.yml' manually if using Drupal 10.)", [':Popper Library' => 'https://popper.js.org/']) . '</dd>';
      $output .= '<dt>' . t('Recommended Themes') . '</dt>';
      $output .= '<dd>' . t("<a href=':Bootstrap SASS'>Bootstrap Barrio 5 SASS sub-theme</a>", [':Bootstrap SASS' => 'https://www.drupal.org/project/bootstrap_sass']) . '</dd>';
      $output .= '<dd>' . t("<a href=':Bootstrap Barrio 5 Theme'>Bootstrap Barrio 5 Theme</a>", [':Bootstrap Barrio 5 Theme' => 'https://www.drupal.org/project/bootstrap_barrio']) . '</dd>';
      $output .= '</dl>';

      return $output;
  }

}

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

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