Hello, any advice would be much appreciated.
I thought I’d use the new ‘Top Navigation Bar’ block instead of the ‘Auto-Nav’ block for my site menu.
However I want to have some links in the menu that are just anchors to scroll to a part of the current page eg #mydiv.
If I just add an external link in the site map this works fine when using the ‘Auto-Nav’ block. However when I use the ‘Top Navigation Bar’ block the link generated includes the whole site path. Therefore the page is refreshed when clicking the link.
Hi @TMDesigns
Thanks, I did look at the view and controller files but I’m still a bit stumped.
In the ‘Top Navigation Bar’ block view file the link is
<?= $item->getUrl() ?>
In the ‘Auto-Nav’ block it’s
$ni->url
This bit in the controller for the ‘Top Navigation Bar’ block seems to refer to $item but I’m still none the wiser about why the link is coming through different
$children = $home->getCollectionChildren();
$navigation = new Navigation();
$current = Page::getCurrentPage();
$parentIDs = $this->getParentIDsToCurrent();
foreach ($children as $child) {
if ($this->includePageInNavigation($child)) {
$item = new PageItem($child);
In the interim, you can probably override either the controller or the view to essentially check for if an entry is an external link and modify behavior accordingly. Not terribly elegant, but this would work for a view override I think:
@rosie607 I recently added getPageItemNavTarget() to the block so I had a good idea what’s going on here. I currently have 2 v9.1.1 installs:
The first has a broken top nav block that always refreshes to the home page with the attached #anchor. (Is this how it’s acting for you? I’m not using pretty url’s so have index.php attached.)
The second install, I believe I have this issue fixed. In this install I can add an external link directly under the home page. Call it footer, link to #footer, and choose NOT to open in new window. Then drop your #footer anchor in a footer global area. No matter what page of the site you are on, the footer link in the top nav block will zip the user to the footer of the page. Is that what you’re looking for. By all appearances and my quick testing that is how the autonav block is rendering it, although I’ve never utilized it before!