Skip to content
Snippets Groups Projects
Commit 1f2f4476 authored by Eric Bremner's avatar Eric Bremner Committed by Kevin Paxman
Browse files

ISTWCMS-4653: fixing getting the menu when using subfoldered Drupal sites

parent 4aff71d7
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !61. Comments created here will be created in the context of that merge request.
...@@ -293,6 +293,11 @@ class UWService implements UWServiceInterface { ...@@ -293,6 +293,11 @@ class UWService implements UWServiceInterface {
*/ */
public function uwGetMenu(string $menu_name = 'main', bool $count_menu_items = FALSE, bool $include_parent_in_count = FALSE): array { public function uwGetMenu(string $menu_name = 'main', bool $count_menu_items = FALSE, bool $include_parent_in_count = FALSE): array {
// The base path, need this for removing when on subfoldered sites,
// for example d8/fdsu5/, we need to remove the fdsu5 from the path
// alias.
global $base_path;
// Get the main menu from the simplify menu module. // Get the main menu from the simplify menu module.
$menu = $this->simplifyMenu->getMenuTree($menu_name); $menu = $this->simplifyMenu->getMenuTree($menu_name);
...@@ -302,8 +307,12 @@ class UWService implements UWServiceInterface { ...@@ -302,8 +307,12 @@ class UWService implements UWServiceInterface {
// Step through each menu and ensure that it is published. // Step through each menu and ensure that it is published.
foreach ($menu as $key => $m) { foreach ($menu as $key => $m) {
// Remove the base path from the url so that we can get
// the actual content from the path alias.
$alias = str_replace($base_path, '', $m['url']);
// Get the path from the URL of the menu link. // Get the path from the URL of the menu link.
$path = $this->pathAliasManager->getPathByAlias($m['url']); $path = $this->pathAliasManager->getPathByAlias('/' . $alias);
// Check if it is a node path and if so check if published. // Check if it is a node path and if so check if published.
if(preg_match('/node\/(\d+)/', $path, $matches)) { if(preg_match('/node\/(\d+)/', $path, $matches)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment