Skip to content

Commit

Permalink
Merge branch 'dev' into usagov-1949-report-issue-incorrect-tab-order
Browse files Browse the repository at this point in the history
  • Loading branch information
YaritzaGarcia authored Oct 2, 2024
2 parents c9f55c1 + f2a20c6 commit 1116c85
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 33 deletions.
36 changes: 4 additions & 32 deletions web/modules/custom/usagov_wizard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,11 @@
## Purpose
Hooks and service to improve Wizard management and customize Wizard display.

### Hooks

* form_alter() - Adds a "view term" button to the modal edit screen
in the wizard manager
* theme_suggestions_page_alter() - Adds a theme suggestions for page templates,
breadcrumbs, and regions based on vocabulary.
* preprocess_page() - Uses the MenuChecker service to put together a left hand
navigation menu that is based on the location of the parent taxonomy in the
menu.
* preprocess_html() - Sends the text from the header_html field to the <head>.

### MenuChecker Service

This service returns information about menu entities. If used in conjunction
with preprocess hooks, it can help generate a custom left navigation menu
comprised of a specific section of a menu. Currently only works for a taxonomy
term page.

By getting an entity from the current route and passing it into
getTermParents(), we can get an array of taxonomy term ids that are parents of
the current entity.

Then, by passing in the machine name of a menu into getMenuEntities(), we can
get an array of taxonomy term ids in the menu, provided they meet certain
conditions. We can also get some information about these entities. We can then
get the parent of these entities, and load all the children.
This service returns information about menu entities. If used in conjunction
with preprocess hooks, it can help generate a custom left navigation menu and/or
mobile nav menu comprised of a specific section of a menu. Currently only works for
a taxonomy term page.

Then, once we have this data, we can check back in usagov_wizard.module
in our preprocess hook to see if there is a match between the ids obtained by
both methods. If there is, then we are on a taxonomy term page which is either
linked to, or has a parent that is linked to, in the menu. And this link in
the menu has a custom field boolean set to true, meaning it is intended to be
used as an anchor to display this section of the menu in the left navigation.

Finally, still in our preprocess hook in usagov_wizard.module,
we can pass the entity information onto our twig template for display.
1 change: 1 addition & 0 deletions web/modules/custom/usagov_wizard/js/expand_collapse.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Expand/collapse all terms in the wizard overview screen.
(function($, Drupal) {
"use strict";
Drupal.behaviors.expand_collapse = {
Expand Down
1 change: 1 addition & 0 deletions web/modules/custom/usagov_wizard/js/unpublished_toggler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Toggle to only show unpublished wizard terms.
(function($, Drupal) {
"use strict";
Drupal.behaviors.unpublishedToggler = {
Expand Down
4 changes: 3 additions & 1 deletion web/modules/custom/usagov_wizard/usagov_wizard.info.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: 'USA Wizard'
type: module
description: 'Hooks, and maybe a service for the wizard content type.'
description: 'Hooks and a service to help manage and display the wizard taxonomy vocabulary.'
core_version_requirement: ^9 || ^10
dependencies:
- hierarchy_manager:hierarchy_manager

0 comments on commit 1116c85

Please sign in to comment.