diff --git a/Block/NodeType/CustomUrl.php b/Block/NodeType/CustomUrl.php index 37e94db7..5032c430 100644 --- a/Block/NodeType/CustomUrl.php +++ b/Block/NodeType/CustomUrl.php @@ -112,4 +112,29 @@ public function getLabel() { return __("Custom Url"); } + + /** + * @param int $nodeId + * + * @return string + */ + public function getCustomUrl($nodeId) + { + $node = $this->nodes[$nodeId]; + $nodeContent = $node->getContent(); + $url = ''; + + if ( + $nodeContent + && $nodeContent !== '#' + && stripos($nodeContent, 'javascript:void') === false + && !$this->isExternalUrl($nodeContent) + ) { + $url = $this->_storeManager->getStore()->getBaseUrl() . ltrim($nodeContent, '/'); + } else { + $url = $nodeContent; + } + + return $url; + } } diff --git a/view/frontend/templates/hyva-menu-footer/menu/node_type/custom_url.phtml b/view/frontend/templates/hyva-menu-footer/menu/node_type/custom_url.phtml index ca44f36a..fc886315 100644 --- a/view/frontend/templates/hyva-menu-footer/menu/node_type/custom_url.phtml +++ b/view/frontend/templates/hyva-menu-footer/menu/node_type/custom_url.phtml @@ -12,15 +12,15 @@ $imageUrl = $block->getImageUrl(); $imageAltText = $block->getImageAltText(); $imageWidth = $block->getImageWidth(); $imageHeight = $block->getImageHeight(); -$content = $block->getContent(); +$url = $block->getCustomUrl($nodeId); $title = $block->getTitle(); $dataAttribute = 'data-menu="menu-' . $nodeId . '"'; $nodeClasses = $block->getNodeClasses(); ?> - + - getTarget()): ?> @@ -36,7 +36,7 @@ $nodeClasses = $block->getNodeClasses(); /> - data-menu="menu-escapeHtmlAttr($nodeId) ?>" diff --git a/view/frontend/templates/hyva-topmenu-desktop/menu/node_type/custom_url.phtml b/view/frontend/templates/hyva-topmenu-desktop/menu/node_type/custom_url.phtml index 97143d24..93d21619 100644 --- a/view/frontend/templates/hyva-topmenu-desktop/menu/node_type/custom_url.phtml +++ b/view/frontend/templates/hyva-topmenu-desktop/menu/node_type/custom_url.phtml @@ -12,15 +12,15 @@ $imageUrl = $block->getImageUrl(); $imageAltText = $block->getImageAltText(); $imageWidth = $block->getImageWidth(); $imageHeight = $block->getImageHeight(); -$content = $block->getContent(); +$url = $block->getCustomUrl($nodeId); $title = $block->getTitle(); $dataAttribute = 'data-menu="menu-' . $nodeId . '"'; $nodeClasses = $block->getNodeClasses(); ?> - + - getTarget()): ?> @@ -36,7 +36,7 @@ $nodeClasses = $block->getNodeClasses(); /> - data-menu="menu-escapeHtmlAttr($nodeId) ?>" diff --git a/view/frontend/templates/hyva-topmenu-mobile/menu/node_type/custom_url.phtml b/view/frontend/templates/hyva-topmenu-mobile/menu/node_type/custom_url.phtml index f185e714..5fd8c452 100644 --- a/view/frontend/templates/hyva-topmenu-mobile/menu/node_type/custom_url.phtml +++ b/view/frontend/templates/hyva-topmenu-mobile/menu/node_type/custom_url.phtml @@ -8,15 +8,15 @@ use Snowdog\Menu\Block\NodeType\CustomUrl; ?> getId(); -$content = $block->getContent(); +$url = $block->getCustomUrl($nodeId); $title = $block->getTitle(); $dataAttribute = 'data-menu="menu-' . $nodeId . '"'; $nodeClasses = $block->getNodeClasses(); ?> - + getTarget()): ?> target="_blank" rel="noopener" diff --git a/view/frontend/templates/menu/node_type/custom_url.phtml b/view/frontend/templates/menu/node_type/custom_url.phtml index 22756b64..d04152ea 100644 --- a/view/frontend/templates/menu/node_type/custom_url.phtml +++ b/view/frontend/templates/menu/node_type/custom_url.phtml @@ -13,7 +13,8 @@ $imageUrl = $block->getImageUrl(); $imageAltText = $block->getImageAltText(); $imageWidth = $block->getImageWidth(); $imageHeight = $block->getImageHeight(); -$content = $block->getContent(); +$nodeId = $block->getId(); +$url = $block->getCustomUrl($nodeId); if ($block->getIsViewAllLink()) { $title = __('View All'); @@ -32,9 +33,9 @@ if ($block->getTarget()) { } $allAttributes = implode(' ', $attributes); ?> - + > escapeHtml($title); ?>