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

VOTE-3075 & VOTE-3077 meta tag help text and title help text #1136

Merged
merged 3 commits into from
Nov 27, 2024
Merged
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
2 changes: 1 addition & 1 deletion config/sync/field.field.node.landing.field_metatags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ field_name: field_metatags
entity_type: node
bundle: landing
label: Metatags
description: ''
description: "Resources for Page Title best practices:\r\n<ul>\r\n<li><a href=\"https://www.w3.org/WAI/WCAG21/Understanding/page-titled.html\" target=\"_blank\">WCAG Page title guide</a></li>\r\n<li><a href=\"https://contentcreation.ai/writing-better-titles\" target=\"_blank\">Writing Better Page Titles for SEO</a></li>\r\n</ul>"
required: false
translatable: true
default_value: { }
Expand Down
2 changes: 1 addition & 1 deletion config/sync/field.field.node.page.field_metatags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ field_name: field_metatags
entity_type: node
bundle: page
label: Metatags
description: ''
description: "Resources for Page Title best practices:\r\n<ul>\r\n<li><a href=\"https://www.w3.org/WAI/WCAG21/Understanding/page-titled.html\" target=\"_blank\">WCAG Page title guide</a></li>\r\n<li><a href=\"https://contentcreation.ai/writing-better-titles\" target=\"_blank\">Writing Better Page Titles for SEO</a></li>\r\n</ul>"
required: false
translatable: true
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ field_name: field_metatags
entity_type: node
bundle: state_territory
label: Metatags
description: ''
description: "Resources for Page Title best practices:\r\n<ul>\r\n<li><a href=\"https://www.w3.org/WAI/WCAG21/Understanding/page-titled.html\" target=\"_blank\">WCAG Page title guide</a></li>\r\n<li><a href=\"https://contentcreation.ai/writing-better-titles\" target=\"_blank\">Writing Better Page Titles for SEO</a></li>\r\n</ul>"
required: false
translatable: true
default_value: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ field_name: field_metatags
entity_type: node
bundle: voter_guide
label: Metatags
description: ''
description: "Resources for Page Title best practices:\r\n<ul>\r\n<li><a href=\"https://www.w3.org/WAI/WCAG21/Understanding/page-titled.html\" target=\"_blank\">WCAG Page title guide</a></li>\r\n<li><a href=\"https://contentcreation.ai/writing-better-titles\" target=\"_blank\">Writing Better Page Titles for SEO</a></li>\r\n</ul>"
required: false
translatable: true
default_value: { }
Expand Down
32 changes: 32 additions & 0 deletions web/modules/custom/vote_utility/inc/form_alter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,38 @@ function vote_utility_form_alter(&$form, FormStateInterface $form_state, $form_i
}
}

/**
* Implements hook_form_FORM_ID_alter().
*/
function vote_utility_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Content types that are not user facing content pages.
$non_content_bundles = [
'node_nvrf_page_edit_form',
'node_nvrf_page_form',
'node_state_territory_edit_form',
'node_state_territory_form',
];
// Content types that are comprised of components.
$landing_bundles = [
'node_landing_edit_form',
'node_landing_form',
];

// Add help text for Title field.
if (!in_array($form_id, $non_content_bundles)) {
if (isset($form['title']) && $form['title']['#access']) {
$form['title']['widget'][0]['value']['#description'] = [
'#markup' => 'This field value will display on the page as a heading level 1. <a href="https://www.w3.org/WAI/tutorials/page-structure/headings/" target="_blank">WCAG heading level guide</a>',
];

// Provide alternative help for a landing page.
if (in_array($form_id, $landing_bundles)) {
$form['title']['widget'][0]['value']['#description'] = 'This field value will not display on the page. Add a Page Component that includes content that displays on the page as a heading level 1.';
}
}
}
}

/**
* Implements hook_form_FORM_ID_alter().
*/
Expand Down