1
votes

We are creating a custom branded Master Page in SharePoint 2010. To make the page similar to a legacy page we have implemented an html based custom dropdown navigation menu we had in place directly on the Master Page (consisted of basic HTML elements ULs and LIs with A tags styled with a CSS class).

I assumed the links from the basic HTML on the page would be subject to Alternate Access Mappings currently in place, but it seems to not be the case. On a test page opened in 3 different URLs (http://sharepoint2010, http://sharepoint2010.mydomain.com, https://sharepoint2010.mydomain.com) the links from a WIKI page are modified as I expected, but the links from the Custom Navigation Menu (plain HTML on the Master Page) are not modified.

I can see where that would be useful... But is there a way that I can add links on the MasterPage in a way that SharePoint parses them first, making them subject to Alternate Access Mapping translation? I tried placing a link inside a SPLinkButton control, but it didn't achieve the desired behavior.

e.g.

<ul id="navmenu">
  <li><SharePoint:SPLinkButton runat="server" NavigateUrl="http://sharepoint2010">sharepoint link</SharePoint:SPLinkButton></li>
  <li><a href="http://sharepoint2010">sharepoint2010</a></li>
  <li>test</li>
</ul>

When I access the page via https://sharepoint2010.mydomain.com the links above are still http://sharepoint2010 rather than https://sharepoint2010.mydomain.com

Any thoughts?

Thanks,

Victor

EDIT (clarify): I was planning on using relative links as a fallback. But for the purpose of what we are doing it would be more maintainable if we could keep the full links and use AAM. I'm aware that standard relative links are a possibility. I was hoping to identify if there is a way to use AAM on Master Page content (or even on Content Retrieved from External Services down the road) by providing a specific link syntax, or control framework.

3

3 Answers

2
votes

There is no need to re-insert the host name if your links are on the same domain and you're not using managed paths. Keeping your links relative will ensure that any bindings in IIS and AAM setup in SharePoint will work without any additional work.

Otherwise, I would heavily suggest to use the available ~sitecollection and ~site SPUrl token to retrieve the current site collection url or current web url. You need to wrap it in anything running server side as the expression will be handled ... server side.

eg:

<asp:Literal runat="server" Text="<% $SPUrl:~site/press-releases/ %>"/>

Hope it helped

1
votes

When you use the NavigateUrl= attribute of the SPLinkButton, SharePoint renders a simple anchor with href= instead of regular PostBack JavaScript code. Alternate access mapping do not play a role here.

1
votes

If its simply relative links you want, then leave out the dns entry altogether (ie the bit of the url you are switching with your AAM) and begin the url with a forward slash to make it relative. If this doesn't meet your needs, the way Sharepoint does it is with a relative url token. Have a look in v4.master for the tilda character followed by 'site' or 'sitecollection' which refers to the current web and site collection respectively. Copy this method. For more details, look at this link: http://msdn.microsoft.com/en-us/library/ms473643.aspx