Skip to content

Commit

Permalink
DIGITAL-30: Add more templates
Browse files Browse the repository at this point in the history
 - Add resources and basic page templates.
 - Add authors template
 - Add Guide templates.
 - Add landing page type field to use for templates suggestions.
 - Migrate event-specific landing page template
 - Migrate community landing page
 - Migrate resources landing page
 - Migrate guide landing page
 - Migrate job board landing page
 - Migrate news landing page
  • Loading branch information
omerida committed Nov 14, 2024
1 parent 93ab993 commit fe0d6a2
Show file tree
Hide file tree
Showing 28 changed files with 1,363 additions and 75 deletions.
11 changes: 11 additions & 0 deletions config/sync/core.entity_form_display.node.guides.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ dependencies:
- field.field.node.guides.field_deck
- field.field.node.guides.field_featured_image
- field.field.node.guides.field_guide_weight
- field.field.node.guides.field_kicker
- field.field.node.guides.field_page_weight
- field.field.node.guides.field_primary_image
- field.field.node.guides.field_summary
- field.field.node.guides.field_summary_box
- field.field.node.guides.field_topics
- node.type.guides
- workflows.workflow.editorial
module:
- content_moderation
- inline_entity_form
- media_library
- path
- text
id: node.guides.default
targetEntityType: node
Expand Down Expand Up @@ -61,6 +64,14 @@ content:
settings:
placeholder: ''
third_party_settings: { }
field_kicker:
type: string_textfield
weight: 1
region: content
settings:
size: 60
placeholder: ''
third_party_settings: { }
field_page_weight:
type: number
weight: 9
Expand Down
21 changes: 15 additions & 6 deletions config/sync/core.entity_form_display.node.landing_page.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ dependencies:
config:
- field.field.node.landing_page.body
- field.field.node.landing_page.field_buttons
- field.field.node.landing_page.field_landing_page_type
- field.field.node.landing_page.field_summary
- node.type.landing_page
- workflows.workflow.editorial
module:
- content_moderation
- link
- path
- text
id: node.landing_page.default
targetEntityType: node
Expand All @@ -18,7 +21,7 @@ mode: default
content:
body:
type: text_textarea_with_summary
weight: 3
weight: 4
region: content
settings:
rows: 9
Expand All @@ -28,7 +31,7 @@ content:
third_party_settings: { }
created:
type: datetime_timestamp
weight: 5
weight: 6
region: content
settings: { }
third_party_settings: { }
Expand All @@ -40,6 +43,12 @@ content:
placeholder_url: ''
placeholder_title: ''
third_party_settings: { }
field_landing_page_type:
type: options_select
weight: 3
region: content
settings: { }
third_party_settings: { }
field_summary:
type: text_textfield
weight: 1
Expand All @@ -50,19 +59,19 @@ content:
third_party_settings: { }
moderation_state:
type: moderation_state_default
weight: 6
weight: 7
region: content
settings: { }
third_party_settings: { }
path:
type: path
weight: 30
weight: 9
region: content
settings: { }
third_party_settings: { }
status:
type: boolean_checkbox
weight: 7
weight: 8
region: content
settings:
display_label: true
Expand All @@ -77,7 +86,7 @@ content:
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 4
weight: 5
region: content
settings:
match_operator: CONTAINS
Expand Down
14 changes: 14 additions & 0 deletions config/sync/core.entity_view_display.node.guides.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies:
- field.field.node.guides.field_deck
- field.field.node.guides.field_featured_image
- field.field.node.guides.field_guide_weight
- field.field.node.guides.field_kicker
- field.field.node.guides.field_page_weight
- field.field.node.guides.field_primary_image
- field.field.node.guides.field_summary
Expand All @@ -28,6 +29,11 @@ content:
third_party_settings: { }
weight: 101
region: content
content_moderation_control:
settings: { }
third_party_settings: { }
weight: -20
region: content
field_deck:
type: text_default
label: above
Expand All @@ -53,6 +59,14 @@ content:
third_party_settings: { }
weight: 127
region: content
field_kicker:
type: string
label: above
settings:
link_to_entity: false
third_party_settings: { }
weight: 116
region: content
field_page_weight:
type: number_integer
label: above
Expand Down
7 changes: 7 additions & 0 deletions config/sync/core.entity_view_display.node.guides.teaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
- field.field.node.guides.field_deck
- field.field.node.guides.field_featured_image
- field.field.node.guides.field_guide_weight
- field.field.node.guides.field_kicker
- field.field.node.guides.field_page_weight
- field.field.node.guides.field_primary_image
- field.field.node.guides.field_summary
Expand All @@ -30,6 +31,11 @@ content:
third_party_settings: { }
weight: 101
region: content
content_moderation_control:
settings: { }
third_party_settings: { }
weight: -20
region: content
links:
settings: { }
third_party_settings: { }
Expand All @@ -39,6 +45,7 @@ hidden:
field_deck: true
field_featured_image: true
field_guide_weight: true
field_kicker: true
field_page_weight: true
field_primary_image: true
field_summary: true
Expand Down
14 changes: 14 additions & 0 deletions config/sync/core.entity_view_display.node.landing_page.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ dependencies:
config:
- field.field.node.landing_page.body
- field.field.node.landing_page.field_buttons
- field.field.node.landing_page.field_landing_page_type
- field.field.node.landing_page.field_summary
- node.type.landing_page
module:
- link
- options
- text
- user
id: node.landing_page.default
Expand All @@ -23,6 +25,11 @@ content:
third_party_settings: { }
weight: 101
region: content
content_moderation_control:
settings: { }
third_party_settings: { }
weight: -20
region: content
field_buttons:
type: link
label: above
Expand All @@ -35,6 +42,13 @@ content:
third_party_settings: { }
weight: 105
region: content
field_landing_page_type:
type: list_default
label: above
settings: { }
third_party_settings: { }
weight: 106
region: content
field_summary:
type: text_default
label: above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies:
- core.entity_view_mode.node.teaser
- field.field.node.landing_page.body
- field.field.node.landing_page.field_buttons
- field.field.node.landing_page.field_landing_page_type
- field.field.node.landing_page.field_summary
- node.type.landing_page
module:
Expand All @@ -24,11 +25,17 @@ content:
third_party_settings: { }
weight: 101
region: content
content_moderation_control:
settings: { }
third_party_settings: { }
weight: -20
region: content
links:
settings: { }
third_party_settings: { }
weight: 100
region: content
hidden:
field_buttons: true
field_landing_page_type: true
field_summary: true
19 changes: 19 additions & 0 deletions config/sync/field.field.node.guides.field_kicker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
uuid: 5b0e584d-be8d-4f09-9200-9f81dfcbbb32
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_kicker
- node.type.guides
id: node.guides.field_kicker
field_name: field_kicker
entity_type: node
bundle: guides
label: Kicker
description: 'Highlight the relevant topic. This displays above the title on the /gudes/ page. Should always be included. Use only one or two words.'
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
uuid: 819799c2-e653-4805-846d-3f97e4541180
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_landing_page_type
- node.type.landing_page
module:
- options
id: node.landing_page.field_landing_page_type
field_name: field_landing_page_type
entity_type: node
bundle: landing_page
label: 'Landing Page Type'
description: 'Select which landing page template and header to use.'
required: true
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: list_string
39 changes: 39 additions & 0 deletions config/sync/field.storage.node.field_landing_page_type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
uuid: c8e15d30-d2bd-4b39-9d00-5462fd559df5
langcode: en
status: true
dependencies:
module:
- node
- options
id: node.field_landing_page_type
field_name: field_landing_page_type
entity_type: node
type: list_string
settings:
allowed_values:
-
value: communities
label: Communities
-
value: events
label: Events
-
value: guides
label: Guides
-
value: job_board
label: 'Job board'
-
value: news
label: News
-
value: resources
label: Resources
allowed_values_function: ''
module: options
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
18 changes: 17 additions & 1 deletion web/themes/custom/digital_gov/digital_gov.theme
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function digital_gov_preprocess_author_image(array &$vars): void {
// choose between light and dark based on length of the slug.
$vars['icon_path'] = sprintf(
'img/digit-%s.png',
strlen($slug ?? $vars['author']['#plain_text']) % 2 ? 'dark' : 'light'
strlen($slug ?? $vars['author']['#title']) % 2 ? 'dark' : 'light'
);
}
break;
Expand Down Expand Up @@ -184,3 +184,19 @@ function digital_gov_preprocess_menu(&$variables, $hook) {
}
}
}

/**
* Implements hook_preprocess_theme_suggestions_node_alter().
*/
function digital_gov_theme_suggestions_node_alter(array &$suggestions, array $variables) {
$node = $variables["elements"]["#node"];

switch ($node->getType()) {
case 'landing_page':
if ($landing_type = $node->field_landing_page_type->value) {
$suggestions[] = 'node__landing_page__' . $landing_type;
$suggestions[] = 'node__landing_page__' . $landing_type . '__' . $variables["elements"]["#view_mode"];
}
break;
}
}

This file was deleted.

Loading

0 comments on commit fe0d6a2

Please sign in to comment.