In a project site there is most likely a contact list, this lists does not only include people involved with the site, it could be suppliers, clients not involved on the project site etc.
There is many ways to this, but I'll take the Out of the box approach, starting simply by adding the Contact list that ships with SharePoint.
Next I add a column to the list, just a Single line of text, this could be named anything you like, but in this example I named it Lync.
Now drop the Contact list in a web zone (or you could edit it in the views). When you go into Edit Web Part and open Miscellaneous you see there is an option to add a XSL Link:
What we need to do now is create a XSL file with a style sheet, this style will add presence based on the Email field in the Contact list. I could have made another field for the SIP address, I'm just lazy since I have never seen anyone used something else than the email for SIP. You could just create a new column in the list called SIP, and use that instead of the Email field. I also use the Title(LastName) and FirstName fields for this.
PS: Make sure those three fields, and the Lync field is marked as visible in the view used by the Web Part.
Now open your favourite text editor, I like to use Notepad++ for work like this.
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office"> <xsl:include href="/_layouts/xsl/main.xsl"/> <xsl:include href="/_layouts/xsl/internal.xsl"/> <xsl:template name="FieldRef_Text_body.Lync" match="FieldRef[@Name='Lync']" mode="Text_body"> <xsl:param name="thisNode" select="."/> <xsl:variable name="etternavn"> <xsl:value-of select="$thisNode/@Title" /> </xsl:variable> <xsl:variable name="fornavn"> <xsl:value-of select="$thisNode/@FirstName" /> </xsl:variable> <xsl:variable name="fulltNavn"> <xsl:value-of select="concat($fornavn,' ',$etternavn)" /> </xsl:variable> <xsl:variable name="itemID"> <xsl:value-of select="$thisNode/@ID" /> </xsl:variable> <xsl:variable name="sipAfter"> <xsl:value-of select="substring-after($thisNode/@Email,':')" /> </xsl:variable> <xsl:variable name="sip"> <xsl:value-of select="substring-before($sipAfter,'"')" /> </xsl:variable> <div id="PresenceLink_{$itemID}"><span class="ms-imnSpan"><img border='0' height='12' src='/_layouts/images/imnhdr.gif' onload="IMNRC('{$sip}')" ShowOfflinePawn='1' style='padding-right: 3px;' id="PresencePawn_{$itemID}" alt='pawn' /> <a href='' id="ProfileLink_{$itemID}"><xsl:value-of select="$fulltNavn" /></a></span></div> </xsl:template> </xsl:stylesheet>
This XSL overrides the default template, and adds a div tag with html in the column Lync instead. First I create a set of variables, they are in Norwegian; etternavn(last name), fornavn(first name), fulltNavn(Full Name), itemID, sipAfter and sip.
The three first variables explains them self, but the reason I use substring-before and subring-after on the Email is because SharePoint(or an IE plugin, haven't checked that) creates a link from emails, with <a href=mailto:> etc. First I take everything after the char ":" and then substrings everything before the '"', '"' is the equivalent to double quote(").
That's all the variables needed to build the presence. If you view the source of any SharePoint site with presence you'll see the same HTML code. I haven't added ProfileLink etc (well its just a href, could be to anything), I just left it in there to show, but it's possible to add a link to lets say the UserProfile, but since these are for non-members of SharePoint its no point. Note: They need unique IDs, that's why I use the itemID variable.
Then its time to save the file and upload it to SharePoint, I just dropped it in the Style Library.
Open the Web Part again and add the link to the file you uploaded.
The result:
Excellent article.exactly what I needed.
ReplyDeleteThanks
BL
Hi, I implemented this but the little coloured box next to the name in the Lync column does not appear in my list. Do you know how to solve this? Thanks
ReplyDelete