- Issue created by @pdureau
- 🇫🇷France pdureau Paris
Before doing the change, let's consider why we may wan to keep those components separated: page.html.twig
When we hardcode the call to a component from this template, we make its slots "configurable", because these are the regions where we put the blocks, but not its props. So menus will not be available anymore.there is a solution cooking on UI SUite USWDS theme:
On theme settings:
protected function menuSettingsForm($title, $value) { $all_menus = $this->entityTypeManager->getStorage('menu')->loadMultiple(); $menus = [ "" => "(None)", ]; foreach ($all_menus as $id => $menu) { $menus[$id] = $menu->label(); } asort($menus); return [ '#type' => 'select', '#title' => $title, '#options' => $menus, '#default_value' => $value, ]; }
it looks like the links settings type, but simpler.
On page preprocess:
protected function addRawMenu(array $variables, string $variable, string $menu_id): array {
$parameters = new MenuTreeParameters();
// Empty parameters because not configurable.
$tree = $this->menuLinkTree->load($menu_id, $parameters);
$manipulators = [
['callable' => 'menu.default_tree_manipulators:checkAccess'],
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
];
$tree = $this->menuLinkTree->transform($tree, $manipulators);
$tree = $this->menuLinkTree->build($tree);
if (!isset($tree["#items"])) {
return $variables;
}
if (isset($tree["#cache"])) {
$variables["#cache"] = array_merge($variables["#cache"] ?? [], $tree["#cache"]);
}
$variables[$variable] = LinksSettingType::normalize($tree["#items"]);
return $variables;
}once again, ike the links settings type, but simple.
- Assigned to pdureau
- Status changed to Postponed
11 months ago 4:08pm 4 February 2024 - 🇫🇷France pdureau Paris
Let's wait the work is merged on USWDS before borrowing.
- Merge request !58Issue #3417519 by pdureau: Merge footer_top into footer component → (Merged) created by pdureau
- Status changed to Needs work
9 months ago 12:34pm 19 March 2024 - Status changed to Needs review
9 months ago 9:50am 22 March 2024 - Issue was unassigned.
- Status changed to RTBC
9 months ago 3:26pm 22 March 2024 - Status changed to Fixed
9 months ago 10:20am 23 March 2024 Automatically closed - issue fixed for 2 weeks with no activity.