On selected portal areas and teamsite pages in Sharepoint you'll get that link "Add to My Links". This link will append an entry of the current url to your MySite "My Links" list. However this feature is not availible on logical locations like the WSS Team Site default.aspx.
This is easy to work around. The script you need to call is PortalPinToMyPage in the ows.js script. The script(s) looks like this:
function PortalPinToMyPage(eForm, portalUrl, instanceID)
eForm.action = portalUrl + '_vti_bin/portalapi.aspx?Cmd=PinToMyPage';
eForm.ReturnUrl.value = window.location.href;
eForm.ListViewUrl.value = MakeMtgInstanceUrl(eForm.ListViewUrl.value, instanceID); eForm.submit();
function MakeMtgInstanceUrl(strUrl, instanceID)
if (instanceID != "undefined" && instanceID != '')
var iQueryString = strUrl.indexOf('?');
if (iQueryString == -1 || strUrl.indexOf('InstanceID=', iQueryString) == -1)
strUrl = strUrl + (iQueryString == -1 ? '?' : '&') + 'InstanceID=' + instanceID;
The script only requires a couple of additional hidden elements to run and by adding this plain html within the form element of any page you'll be set:
<INPUT Type="Hidden" Name="ListViewUrl" Value="http://www.yourpage.no">
<INPUT Type="Hidden" Name="BaseType" Value="0">
<INPUT Type="Hidden" Name="ServerTemplate" Value="106">
<INPUT Type="Hidden" Name="ReturnUrl" Value="">
I tried referencing the form with another name but that didn't seem to work. Note that you'll have to enter the page url to the ListViewUrl property, and that the ServerTemplate and BaseType determines how the link is displayed on MySite. ReturnUrl is set automatically.
In my case I want to add this code to a WSS Site template, thus the URL will change for each site instance. The big stupid thing about this script is that the URL needs to be hardcoded in the hidden element ListViewUrl. To work around this it's needed to assign the current url to the hidden field. Replace the link tag with this one:
<a onclick='document.forms[MSOWebPartPageFormName].ListViewUrl.value = document.location'
When placing this link on a teamsite you probably want to place this link in the left navigation pane of the default.aspx page. By default the form tag on the teamsite main page is placed below the html markup for the left navbar. I simply moved the form tag app. 25 lines up to include the table containing the left navbar items and added the link to the bottom of this table. Works like a charm.
Want to get the title of the WSS site automatically transferred to the Add to My Links aswell? Add this to the hidden fields above:
<INPUT Type="Hidden" Name="ListTitle" Value='<SharePoint:ProjectProperty Property="Title" runat="server"/>'>