简体   繁体   English

Sharepoint母版页中的相对URL

[英]Relative URLs in Sharepoint master page

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 . 例如,我希望计划链接转到http://Server/Subsite/Pages/Tab2.aspx Instead, what I am getting is http://Server/Pages/Tab2.aspx . 相反,我得到的是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. 我读到在链接开头有一个波形符号可以解决这个问题,但事实并非如此。

I spent HOURS looking for the answer to this question, and it turns out there IS one, it's just annoying. 我花了HOURS寻找这个问题的答案,事实证明那是一个,这只是烦人的。 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. 您可以在WSS站点和MOSS站点中使用ProjectProperty标记,ProjectProperty的一个可能参数为您提供子站点的URL。

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

That outputs a string literal with the value of the subsite URL. 这将输出带有子网站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): 因此,例如,您可以执行此操作(请注意,您需要对实际HTML标记的src =''或href =''属性使用单引号):

<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!) 有关ProjectProperty的其他可能值的列表,请查看此人的页面 (这是我找到原始答案的位置!)

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... 我正在寻找一个答案,这样做很长一段时间......我想把我的网站打包成一个网站模板,绝对的网址不是一个选项...我需要他们相对于网站的URL是什么......无论是MOSS的根源还是结构深处的子站点......

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): 样式表(上面由user385947建议的方法):

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

Hope this helps others... 希望这有助于其他人......

您正在寻找〜站点令牌, 这里是WSS定制的URL令牌列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM