-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap_layout_builder.module
More file actions
64 lines (58 loc) · 1.56 KB
/
bootstrap_layout_builder.module
File metadata and controls
64 lines (58 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @file
* Bootstrap Layout Builder module.
*/
use Drupal\Core\Render\Element;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function bootstrap_layout_builder_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the bootstrap_layout_builder module.
case 'help.page.bootstrap_layout_builder':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Add Bootstrap Grid support to Layout Builder module.
currently, work for both Bootstrap 3 and Bootstrap 4.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function bootstrap_layout_builder_theme() {
return [
'blb_container_wrapper' => [
'variables' => [
'attributes' => [],
'children' => [],
],
],
'blb_container' => [
'variables' => [
'attributes' => [],
'children' => [],
],
],
'blb_section' => [
'template' => 'blb-section',
'render element' => 'content',
'base hook' => 'layout',
],
];
}
/**
* Implements hook_preprocess_HOOK().
*/
function bootstrap_layout_builder_preprocess_blb_section(&$variables) {
foreach (Element::children($variables['content']) as $name) {
if (!isset($variables['content'][$name]['#attributes'])) {
$variables['content'][$name]['#attributes'] = [];
}
$variables['region_attributes'][$name] = new Attribute($variables['content'][$name]['#attributes']);
}
}