I need to add a <link>
tag with a dynamic src attribute to a custom masterpage <head>
section pointing to a current SPWeb library like this:
<link rel="alternate" type="application/rss+xml" title="RSS Comments" href='http://server/site/mylib/rss.xml'></link>
It should work with SharePoont Foundation and SharePoint Server without developing custom code (like a WebControl) to work in a sandboxed/hosted environment.
I don't have a problem using:
<link rel="alternate" type="application/rss+xml" href='/mylib/rss.xml'></link>
but this is an absolute url and points to the site collection root SPWeb and resolves to:
<link rel="alternate" type="application/rss+xml" href='http://server/mylib/rss.xml'></link>
Hence this will fail if the SPWeb is located at http://server/site/default.aspx
.
I've already tried with:
<link rel="alternate" type="application/rss+xml" href='mylib/rss.xml'></link>
But that doesn't work at all creating an invalid link to "_catalogs/masterpage".
I've also tried with $SPUrl but thats only available to SharePoint Server and not Foundation.
I then started to play with:
<SharePoint:ProjectProperty Property="Url" runat="server" />
It works without an issue inside a <script>
tag (and I assume <style>
works too) like this:
<script language="javascript" src='<SharePoint:ProjectProperty Property="Url" runat="server" />/mylib/script.js' type="text/javascript"></script>
and the result is:
<script language="javascript" src='http://server/site/mylib/script.js' type="text/javascript"></script>
However, when I try the following:
<link rel="alternate" type="application/rss+xml" href='<SharePoint:ProjectProperty Property="Url" runat="server" />/mylib/rss.xml'></link>
all thats rendered in the browser HTML source is:
<link rel="alternate" type="application/rss+xml" href="<SharePoint:ProjectProperty Property="Url" runat="server" />/mylib/rss.xml" /></link>
Note that using "mylib/rss.xml" just serves as an example to keep my post simple but is not the real path and file (which is more complex).
So the question is, how to format the link tag properly to make it work.
Anybody has an idea what I'm doing wrong?