bootstrap_five_layouts-1.0.x-dev/modules/bootstrap_five_layouts_viewsstyle/bootstrap_five_layouts_viewsstyle.module
modules/bootstrap_five_layouts_viewsstyle/bootstrap_five_layouts_viewsstyle.module
<?php
/**
* @file
* Custom functions for Views Bootstrap.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\bootstrap_five_layouts_viewsstyle\BootstrapFiveLayoutsViewsstyle;
/**
* Implements hook_help().
*/
function bootstrap_five_layouts_viewsstyle_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.bootstrap_five_layouts_viewsstyle':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The <a href="https://www.drupal.org/project/bootstrap_five_layouts">bootstrap five layouts viewstyle</a> adds styles to Views to output the results of a view as several common <a href="http://getbootstrap.com/components/">Twitter Bootstrap</a> components.') . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<p>' . t('<a href="/admin/structure/views/add">Create a view</a> using one of the following styles:') . '</p>';
$output .= '<ul>';
$output .= '<li>' . t('<a href="https://getbootstrap.com/docs/5.1/layout/">Bootstrap5 Layout/Grid</a>') . '</li>';
$output .= '<li>' . t('<a href="https://getbootstrap.com/docs/5.1/utilities/">Bootstrap5 Utility</a>') . '</li>';
$output .= '<li>' . t('<a href="https://getbootstrap.com/docs/5.1/helpers/">Bootstrap5 Helpers</a>') . '</li>';
$output .= '</ul>';
return $output;
}
}
/**
* Implements hook_theme().
*/
function bootstrap_five_layouts_viewsstyle_theme() {
return BootstrapFiveLayoutsViewsstyle::getThemeHooks();
}
/**
* Implements hook_theme_suggestions_HOOK_alter().
*
* Add views styles template suggestions.
*
* {@inheritdoc}
*/
function bootstrap_five_layouts_viewsstyle_theme_suggestions_alter(array &$suggestions, array &$variables, $hook): void {
if (isset($variables['view']) && str_starts_with($hook, 'bootstrap_five_layouts_viewsstyle_')) {
$view = $variables['view'];
$style_name = $view->style_plugin->getPluginId();
// Add custom theme suggestions.
$suggestions[] = $style_name . '__' . $view->id();
$suggestions[] = $style_name . '__' . $view->current_display;
$suggestions[] = $style_name . '__' . $view->id() . '__' . $view->current_display;
}
}
