Skip to content
Snippets Groups Projects
Commit 56e215d0 authored by Alberto Siles's avatar Alberto Siles
Browse files

Make region setup administrable

parent f3823fb8
No related branches found
No related tags found
No related merge requests found
......@@ -300,6 +300,16 @@ function bootstrap_barrio_preprocess_node(&$variables) {
}
}
/**
* Implements hook_preprocess_HOOK() for region.html.twig.
*/
function bootstrap_barrio_preprocess_region(&$variables) {
// Add a clearfix class to system branding blocks.
if (theme_get_setting('bootstrap_barrio_region_class_' . $variables['elements']['#region']) !== NULL) {
$variables['region_classes'] = theme_get_setting('bootstrap_barrio_region_class_' . $variables['elements']['#region']);
}
}
/**
* Implements hook_preprocess_HOOK() for block.html.twig.
*/
......@@ -372,7 +382,13 @@ function bootstrap_barrio_theme_suggestions_region_alter(array &$suggestions, ar
'sidebar_first',
'sidebar_second',
];
if ( in_array($variables['elements']['#region'], $nowrap) ) {
if ( theme_get_setting('bootstrap_barrio_region_class_' . $variables['elements']['#region']) !== NULL) {
$region_clean = theme_get_setting('bootstrap_barrio_region_class_' . $variables['elements']['#region']);
}
else {
$region_clean = in_array($variables['elements']['#region'], $nowrap);
}
if ( $region_clean ) {
$suggestions[] = 'region__nowrap';
}
}
......
......@@ -15,7 +15,6 @@
{%
set classes = [
'region',
'row',
'region-' ~ region|clean_class,
]
%}
......
......@@ -76,6 +76,60 @@ function bootstrap_barrio_form_system_theme_settings_alter(&$form, FormStateInte
)),
);
// List of regions
$theme = \Drupal::theme()->getActiveTheme()->getName();
$region_list = system_region_list($theme, $show = REGIONS_ALL);
// Only for initial setup if not defined on install
$nowrap = [
'breadcrumb',
'content',
'primary_menu',
'header',
'sidebar_first',
'sidebar_second',
];
//Region
$form['layout']['region'] = array(
'#type' => 'details',
'#title' => t('Region'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
foreach ($region_list as $name => $description) {
if ( theme_get_setting('bootstrap_barrio_region_clean_' . $name) !== NULL) {
$region_clean = theme_get_setting('bootstrap_barrio_region_clean_' . $name);
}
else {
$region_clean = in_array($name, $nowrap);
}
if ( theme_get_setting('bootstrap_barrio_region_class_' . $name) !== NULL) {
$region_class = theme_get_setting('bootstrap_barrio_region_class_' . $name);
}
else {
$region_class = $region_clean ? NULL : 'row';
}
$form['layout']['region'][$name] = array(
'#type' => 'details',
'#title' => $description,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['layout']['region'][$name]['bootstrap_barrio_region_clean_' . $name] = array(
'#type' => 'checkbox',
'#title' => t('Clean wrapper for @description region', array('@description' => $description)),
'#default_value' => $region_clean,
);
$form['layout']['region'][$name]['bootstrap_barrio_region_class_' . $name] = array(
'#type' => 'textfield',
'#title' => t('Classes for @description region', array('@description' => $description)),
'#default_value' => theme_get_setting('bootstrap_barrio_region_class_' . $name),
'#size' => 40,
'#maxlength' => 40,
);
}
// Sidebar Position
$form['layout']['sidebar_position'] = array(
'#type' => 'details',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment