views:

456

answers:

4

I have a master page with tabs. The tabs are defined by the following sitemap file:

<siteMap>
    <siteMapNode title="Home" url="~/" >
        <siteMapNode title="Schedule" url="~/Pages/Tab2.aspx"/>      
        <siteMapNode title="Deliverables" url="~/Pages/Tab3.aspx"/>
        <siteMapNode title="My Items" url="~/Pages/Tab4.aspx"/>
        <siteMapNode title="Management" url="~/Pages/Tab5.aspx"/>
        <siteMapNode title="Working Docs" url="~/Pages/Tab6.aspx"/>
    </siteMapNode>
</siteMap>

The problem is that on my subsites, clicking on a tab keeps taking me back to the root. For example, I want the schedule link to go to http://Server/Subsite/Pages/Tab2.aspx. Instead, what I am getting is http://Server/Pages/Tab2.aspx. I read that having a tilde at the beginning of the link would solve this problem but it doesn't.

+1  A: 

You're looking for the ~site token, here's a list of the URL tokens custom to WSS.

OedipusPrime
~site is not working for me. The link becomes http://Server/~site/Pages/Tab2.aspx. Maybe this doesn't work in a sitemap file?
DL
Hmm, I posted under the assumption that the token replacement was being done in one of the SharePoint HTTPHandlers, which means it should work in the site map, but after looking at this SO post: http://stackoverflow.com/questions/337781/creating-custom-url-tokens-in-asp-net-a-la-moss it appears the tokens are actually parsed somewhere else. Regardless the ~ token is always relative to the web app root, not the current site/site collection in SharePoint. You may need to implement your own site map provider to get the functionality you're really looking for, sorry for the misleading answer.
OedipusPrime
A: 

It seems like there should be a simple solution to this. People must have to link to pages that are not relative to the root, but relative to a subsite.

DL
A: 

I spent HOURS looking for the answer to this question, and it turns out there IS one, it's just annoying. You can use the ProjectProperty tag in WSS sites AND MOSS sites, and one of the possible parameters for ProjectProperty gives you the subsite's URL.

<SharePoint:ProjectProperty Property="Url" runat="server"/>

That outputs a string literal with the value of the subsite URL. So, for example, you can do this (note that you need to use single-quotes for the src='' or href='' attribute of the actual HTML tag):

<a href='<SharePoint:ProjectProperty Property="Url" runat="server"/>/pages/Tab2.aspx'>

Hope it helps! For a listing of other possible values for ProjectProperty, check out this guy's page (which is where i found my original answer!)

A: 

I was looking for an answer to do this for a long time... I want to package my site as a Site Template and having absolute URLs was not an option... I need them to be relative to what ever the site URL is... whether it is at the root of MOSS or a sub-site deep down in the structure...

I found the following to work:

Script Tags:

<script type="text/javascript" src='<asp:Literal runat="server" 
               Text="<% $SPUrl:~Site/appBin/js/jquery.min.js %>" />'></script>

Style sheet (Method suggested above by user385947):

<link rel="stylesheet" type="text/css" 
       href="<% $SPUrl:~Site/appBin/css/jquery-ui.css %>" />

Hope this helps others...

Paul T.