Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds field for guide navigation layout type #182

Open
wants to merge 4 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ status: true
dependencies:
config:
- field.field.node.localgov_guides_overview.body
- field.field.node.localgov_guides_overview.localgov_guides_list_layout
- field.field.node.localgov_guides_overview.localgov_guides_list_format
- field.field.node.localgov_guides_overview.localgov_guides_pages
- field.field.node.localgov_guides_overview.localgov_guides_section_title
Expand Down Expand Up @@ -38,6 +39,12 @@ content:
region: content
settings: { }
third_party_settings: { }
localgov_guides_list_layout:
type: options_select
weight: 4
region: content
settings: { }
third_party_settings: { }
localgov_guides_pages:
type: localgov_entity_reference_labels
weight: 14
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
langcode: en
status: true
dependencies:
config:
- field.storage.node.localgov_guides_list_layout
- node.type.localgov_guides_overview
module:
- options
id: node.localgov_guides_overview.localgov_guides_list_layout
field_name: localgov_guides_list_layout
entity_type: node
bundle: localgov_guides_overview
label: 'List Layout'
description: ''
required: false
translatable: false
default_value:
-
value: vertical
default_value_callback: ''
settings: { }
field_type: list_string
26 changes: 26 additions & 0 deletions config/install/field.storage.node.localgov_guides_list_layout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
langcode: en
status: true
dependencies:
module:
- node
- options
id: node.localgov_guides_list_layout
field_name: localgov_guides_list_layout
entity_type: node
type: list_string
settings:
allowed_values:
-
value: horizontal
label: 'Horizontal (multiple columns)'
-
value: vertical
label: 'Vertical (single column)'
allowed_values_function: ''
module: options
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ status: true
dependencies:
enforced:
module:
- localgov_guides
- localgov_menu_link_group
- localgov_guides
- localgov_menu_link_group
id: localgov_menu_link_group_guide
group_label: Guide
weight: 0
Expand Down
14 changes: 14 additions & 0 deletions src/Plugin/Block/GuidesContentsBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ class GuidesContentsBlock extends GuidesAbstractBaseBlock {
public function build() {
$this->setPages();
$links = [];
$layout_type = FALSE;

if ($this->overview->hasField('localgov_guides_list_layout')) {
$layout_type_field = $this->overview->get('localgov_guides_list_layout');
if (!empty($layout_type_field) && isset($layout_type_field->getValue()[0])) {
$layout_type = $layout_type_field->getValue()[0]['value'];
$layout_type = str_replace('_', '-', $layout_type);
}
}

$options = $this->node->id() == $this->overview->id() ? ['attributes' => ['class' => 'active']] : [];
$links[] = $this->overview->toLink($this->overview->localgov_guides_section_title->value, 'canonical', $options);

foreach ($this->guidePages as $guide_node) {
$options = $this->node->id() == $guide_node->id() ? ['attributes' => ['class' => 'active']] : [];
$links[] = $guide_node->toLink($guide_node->localgov_guides_section_title->value, 'canonical', $options);
Expand All @@ -35,6 +45,10 @@ public function build() {
'#format' => $this->format,
];

if ($layout_type) {
$build['#attributes']['class'][] = 'block-localgov-guides-contents--' . $layout_type;
}

return $build;
}

Expand Down
Loading