If you are familiar with SharePoint Portal 2007 you will be aware that there is now the ability to have your own personalized list of links (‘My Links’) which you can share with everyone, just certain colleagues or even for yourself. Using the ‘My Links’ button in your navigation you can easily get to these links, and also add a new link.
What I discovered today though was how you can impersonate the ability to add a new link to this list – as you might want to add a link on certain (or even every) page. This gives users the ability to click ‘bookmark’ or ‘add to my links’ easily. The link is then added to their own personal links – essentially building up their own favourites within SharePoint.
The client script responsible for helping out here is AddToQuickLinksDialog(templateId, baseUrl). If you add this into a control you then will be able to harness all the power of the ‘My Links’ control from where ever you like in your portal – including the control identifying the url that you are on and adding this into your link.
So for example to create a button for bookmarking any page, you would simply add the following into your masterpage:
<asp:Button OnClientClick="AddToQuickLinksDialog('thisbutton','http://SharePointURL/');" runat="server" ID="thisbutton" Text="Bookmark this page!"></asp:Button>