diff --git a/bootstrap_layouts.module b/bootstrap_layouts.module
index 6f0dba5..2d5b93b 100644
--- a/bootstrap_layouts.module
+++ b/bootstrap_layouts.module
@@ -101,6 +101,12 @@ function _bootstrap_layouts_preprocess_layout(array &$variables) {
$variables[$entity_type] = $entity;
}
+ // Add Container and section attributes.
+ $variables['container'] = $layout->getSetting('layout.container', FALSE);
+ $section_attributes = isset($variables['section_attributes']) ? $variables['section_attributes'] : [];
+ $section_attributes = NestedArray::mergeDeep(_bootstrap_layouts_parse_attributes($layout->getSetting('layout.section_attributes'), $tokens), $section_attributes);
+ $variables['section_attributes'] = new Attribute($section_attributes);
+
// Add a layout wrapper and its attributes.
$variables['wrapper'] = $layout->getSetting('layout.wrapper', 'div');
$layout_attributes = isset($variables['attributes']) ? $variables['attributes'] : [];
diff --git a/src/Plugin/Layout/BootstrapLayoutsBase.php b/src/Plugin/Layout/BootstrapLayoutsBase.php
index 1c84a5b..ae53b1c 100644
--- a/src/Plugin/Layout/BootstrapLayoutsBase.php
+++ b/src/Plugin/Layout/BootstrapLayoutsBase.php
@@ -44,6 +44,8 @@ class BootstrapLayoutsBase extends LayoutDefault implements PluginFormInterface
$configuration = parent::defaultConfiguration();
$configuration += [
'layout' => [
+ 'container' => FALSE,
+ 'section_attributes' => '',
'wrapper' => 'div',
'classes' => ['row'],
'attributes' => '',
@@ -113,6 +115,24 @@ class BootstrapLayoutsBase extends LayoutDefault implements PluginFormInterface
'#tree' => TRUE,
];
+ $form['layout']['container'] = array(
+ '#title' => $this->t('Add Bootstrap Container'),
+ '#type' => 'checkbox',
+ '#default_value' => $complete_form_state->getValue(['layout', 'container'], $configuration['layout']['container']),
+ );
+
+ $form['layout']['section_attributes'] = [
+ '#title' => $this->t('Section Attributes'),
+ '#type' => 'textfield',
+ '#default_value' => $complete_form_state->getValue(['layout', 'section_attributes'], $configuration['layout']['section_attributes']),
+ '#states' => [
+ 'visible' => [
+ ':input[name="layout_settings[layout][container]"]' => ['checked' => TRUE],
+ ],
+ ],
+ '#description' => $this->t('E.g. class|class-1 class-2,id|custom-id,data-something|some value'),
+ ];
+
$form['layout']['wrapper'] = [
'#type' => 'select',
'#title' => $this->t('Wrapper'),
@@ -231,6 +251,7 @@ class BootstrapLayoutsBase extends LayoutDefault implements PluginFormInterface
$defaults = $this->getRegionDefaults();
if ($layout = $form_state->getValue('layout', $defaults)) {
// Apply Xss::filter to attributes.
+ $layout['section_attributes'] = Xss::filter($layout['section_attributes']);
$layout['attributes'] = Xss::filter($layout['attributes']);
$this->configuration['layout'] = $layout;
}
diff --git a/templates/3.0.0/bs-1col-stacked.html.twig b/templates/3.0.0/bs-1col-stacked.html.twig
index f4346c1..afc345e 100644
--- a/templates/3.0.0/bs-1col-stacked.html.twig
+++ b/templates/3.0.0/bs-1col-stacked.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "1 Column (stacked)" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -18,6 +20,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -40,3 +46,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-1col.html.twig b/templates/3.0.0/bs-1col.html.twig
index caa67d3..ddc3ba0 100644
--- a/templates/3.0.0/bs-1col.html.twig
+++ b/templates/3.0.0/bs-1col.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "1 Column" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -16,9 +18,17 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
<{{ main.wrapper }}{{ main.attributes }}>
{{ main.content }}
{{ main.wrapper }}>
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-2col-bricked.html.twig b/templates/3.0.0/bs-2col-bricked.html.twig
index 210125d..9dbda9e 100644
--- a/templates/3.0.0/bs-2col-bricked.html.twig
+++ b/templates/3.0.0/bs-2col-bricked.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "2 Columns (stacked)" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -22,6 +24,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -68,3 +74,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-2col-stacked.html.twig b/templates/3.0.0/bs-2col-stacked.html.twig
index 20f0a13..67f93ce 100644
--- a/templates/3.0.0/bs-2col-stacked.html.twig
+++ b/templates/3.0.0/bs-2col-stacked.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "2 Columns (stacked)" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -19,6 +21,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -47,3 +53,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-2col.html.twig b/templates/3.0.0/bs-2col.html.twig
index b2c2dc3..7336c7f 100644
--- a/templates/3.0.0/bs-2col.html.twig
+++ b/templates/3.0.0/bs-2col.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "2 Columns" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -17,6 +19,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -33,3 +39,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-3col-bricked.html.twig b/templates/3.0.0/bs-3col-bricked.html.twig
index 1d9dc76..dcdcea4 100644
--- a/templates/3.0.0/bs-3col-bricked.html.twig
+++ b/templates/3.0.0/bs-3col-bricked.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "3 Columns (bricked)" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -24,6 +26,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -82,3 +88,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-3col-stacked.html.twig b/templates/3.0.0/bs-3col-stacked.html.twig
index 81e15f2..45da2a7 100644
--- a/templates/3.0.0/bs-3col-stacked.html.twig
+++ b/templates/3.0.0/bs-3col-stacked.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "3 Columns (stacked)" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -20,6 +22,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -54,3 +60,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-3col.html.twig b/templates/3.0.0/bs-3col.html.twig
index 91be405..de2354f 100644
--- a/templates/3.0.0/bs-3col.html.twig
+++ b/templates/3.0.0/bs-3col.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "3 Columns" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -18,6 +20,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -40,3 +46,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-4col-bricked.html.twig b/templates/3.0.0/bs-4col-bricked.html.twig
index 7a64892..a3283bd 100644
--- a/templates/3.0.0/bs-4col-bricked.html.twig
+++ b/templates/3.0.0/bs-4col-bricked.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "4 Columns (bricked)" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -26,6 +28,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -96,3 +102,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-4col-stacked.html.twig b/templates/3.0.0/bs-4col-stacked.html.twig
index cd06507..31355d5 100644
--- a/templates/3.0.0/bs-4col-stacked.html.twig
+++ b/templates/3.0.0/bs-4col-stacked.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "4 Columns (stacked)" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -21,6 +23,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -61,3 +67,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}
diff --git a/templates/3.0.0/bs-4col.html.twig b/templates/3.0.0/bs-4col.html.twig
index 0a1f289..d0fb4e2 100644
--- a/templates/3.0.0/bs-4col.html.twig
+++ b/templates/3.0.0/bs-4col.html.twig
@@ -4,6 +4,8 @@
* Bootstrap Layouts: "4 Columns" template.
*
* Available layout variables:
+ * - container: A boolean indicating whether to add a contianing div or not.
+ * - section_attributes: Attributes for the section when a container is used.
* - wrapper: Wrapper element for the layout container.
* - attributes: Wrapper attributes for the layout container.
*
@@ -19,6 +21,10 @@
* - content: The content to go inside the wrapper for this region.
*/
#}
+{% if container %}
+
+
+{% endif %}
<{{ wrapper }}{{ attributes }}>
{{ title_suffix.contextual_links }}
@@ -47,3 +53,7 @@
{% endif %}
{{ wrapper }}>
+{% if container %}
+
+
+{% endif %}