Skip to content
Snippets Groups Projects
Commit 7854218d authored by Eric Bremner's avatar Eric Bremner
Browse files

ISTWCMS-4053: adding five column layout and updating layout names

parent c3d9092b
No related branches found
No related tags found
No related merge requests found
<?php
namespace Drupal\uw_cfg_common\Plugin\Layout;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Plugin\PluginFormInterface;
/**
* A UW four column layout.
*
* @Layout(
* id = "uw_five_column",
* label = @Translation("Five columns"),
* category = @Translation("UW layouts"),
* template = "templates/layout/layout--uwfivecol",
* regions = {
* "first" = {
* "label" = @Translation("Column 1"),
* },
* "second" = {
* "label" = @Translation("Column 2"),
* },
* "third" = {
* "label" = @Translation("Column 3"),
* },
* "fourth" = {
* "label" = @Translation("Column 4"),
* },
* "fifth" = {
* "label" = @Translation("Column 5"),
* },
* }
* )
*/
class UwFiveColumnLayout extends LayoutDefault implements PluginFormInterface {
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
// Get the config for this layout.
$configuration = $this->getConfiguration();
// The options for the column widths.
$options = [
'even-split' => $this->t('Even split (20%, 20%, 20%, 20%, 20%)'),
'larger-left' => $this->t('Larger left (40%, 15%, 15%, 15%, 15%)'),
'larger-second' => $this->t('Larger second (15%, 40%, 15%, 15%, 15%)'),
'larger-third' => $this->t('Larger third (15%, 15%, 40%, 15%, 15%)'),
'larger-fourth' => $this->t('Larger fourth (15%, 15%, 15%, 40%, 15%)'),
'larger-right' => $this->t('Larger right (15%, 15%, 15%, 15%, 40%)'),
'legacy-23-19-19-19-20' => $this->t('Legacy (23%, 19%, 19%, 19%, 20%)'),
];
// The form element for the column widths.
$form['layout_settings']['column_class'] = [
'#type' => 'select',
'#title' => $this->t('Column widths'),
'#default_value' => !empty($configuration['column_class']) ? $configuration['column_class'] : 'even-split',
'#options' => $options,
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Set the column class in the config.
$this->configuration['column_class'] = $form_state->getValue(['layout_settings', 'column_class'], NULL);
}
/**
* {@inheritdoc}
*/
public function build(array $regions) {
// Build the render array as usual.
$build = parent::build($regions);
// Retrieve the config for the layout.
$configuration = $this->getConfiguration();
// Set the column class to be used in the layout template.
$build['#settings']['column_class'] = $configuration['column_class'];
return $build;
}
}
uw_one_column: uw_one_column:
label: 'UW One column' label: 'One column'
category: 'UW layouts' category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwOneColumnLayout' class: '\Drupal\uw_cfg_common\Plugin\Layout\UwOneColumnLayout'
template: uw_fdsu_theme_resp/templates/layout/layout--uwonecol template: uw_fdsu_theme_resp/templates/layout/layout--uwonecol
...@@ -10,7 +10,7 @@ uw_one_column: ...@@ -10,7 +10,7 @@ uw_one_column:
icon_map: icon_map:
- [first] - [first]
uw_two_column: uw_two_column:
label: 'UW Two columns' label: 'Two columns'
category: 'UW layouts' category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwTwoColumnLayout' class: '\Drupal\uw_cfg_common\Plugin\Layout\UwTwoColumnLayout'
template: uw_fdsu_theme_resp/templates/layout/layout--uwtwocol template: uw_fdsu_theme_resp/templates/layout/layout--uwtwocol
...@@ -23,7 +23,7 @@ uw_two_column: ...@@ -23,7 +23,7 @@ uw_two_column:
icon_map: icon_map:
- [first, second] - [first, second]
uw_three_column: uw_three_column:
label: 'UW Three columns' label: 'Three columns'
category: 'UW layouts' category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwThreeColumnLayout' class: '\Drupal\uw_cfg_common\Plugin\Layout\UwThreeColumnLayout'
template: uw_fdsu_theme_resp/templates/layout/layout--uwthreecol template: uw_fdsu_theme_resp/templates/layout/layout--uwthreecol
...@@ -38,7 +38,7 @@ uw_three_column: ...@@ -38,7 +38,7 @@ uw_three_column:
icon_map: icon_map:
- [first, second, third] - [first, second, third]
uw_four_column: uw_four_column:
label: 'UW Four columns' label: 'Four columns'
category: 'UW layouts' category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwFourColumnLayout' class: '\Drupal\uw_cfg_common\Plugin\Layout\UwFourColumnLayout'
template: uw_fdsu_theme_resp/templates/layout/layout--uwfourcol template: uw_fdsu_theme_resp/templates/layout/layout--uwfourcol
...@@ -54,3 +54,22 @@ uw_four_column: ...@@ -54,3 +54,22 @@ uw_four_column:
label: Fourth label: Fourth
icon_map: icon_map:
- [first, second, third, fourth] - [first, second, third, fourth]
uw_five_column:
label: 'Five columns'
category: 'UW layouts'
class: '\Drupal\uw_cfg_common\Plugin\Layout\UwFiveColumnLayout'
template: uw_fdsu_theme_resp/templates/layout/layout--uwfivecol
default_region: first
regions:
first:
label: One
second:
label: Two
third:
label: Third
fourth:
label: Fourth
fifth:
label: Fifth
icon_map:
- [first, second, third, fourth, fifth]
\ No newline at end of file
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