Internal Navigation link fix-option


Replacement for in 2.2 branch (works for 2.5 too). Handles problem (if its a problem for you) where internal links are not relative.  If you have a host A with alias B and get to the page with 


the current navigation links will all have http://A/link.html in them  which means that after the first click, users will find themselves on a different host.

Main code fix below.

also  list_menus.vtl needs extra logic to handle relative internal links (inside the LINKS part @ line 17)

#if ($UtilMethods.isSet($menuItem.linktype) && $menuItem.linkType=="INTERNAL")
    #set ($link = "${}")
    #set ($link = "${menuItem.protocal}${}")

Attachment: (100 KB)


basic logic is :
String linkHost = link.getUrl().indexOf("/")==-1?link.getUrl():link.getUrl().substring(0, link.getUrl().indexOf("/"));
                            boolean hostLocal = host.getHostname().equals(linkHost) || host.getAliases().contains(linkHost);
                            if (link.getLinkType().equals(LinkType.EXTERNAL.toString()) || !hostLocal) {                            
                               .. do external link stuff
                            } else {
                               .. do internal link stuff