TwitterLinkedInBlog

Wednesday, July 23, 2014

Content Query Web Part (CQWP) - Author with Presence

Exerpt taken directly from:
http://social.technet.microsoft.com/Forums/sharepoint/en-US/fb79d25c-78b7-452e-9c94-bb5e29063b0c/displaying-authors-with-presence-information-in-a-content-query-web-part-cqwp?forum=sharepointcustomizationprevious

Add the following template to "ContentQueryMain":
 <xsl:template name="OuterTemplate.AuthorPresence">
  <xsl:param name="Author" select="." />
  <xsl:variable name="sEmail" select="ddwrt:UserLookup(string($Author) ,'EMail')" />
  <xsl:variable name="sID" select="ddwrt:UserLookup(string($Author) ,'ID')" />
  <a href="{concat('/_Layouts/userdisp.aspx?ID=', $sID)}" onclick="GoToLinkOrDialogNewWindow(this);return false;">
   <xsl:value-of select="$Author" />
  </a> 
  <img src="/_layouts/images/blank.gif" height="1" width="3" />
  <a href="javascript:" class="ms-imnlink">
   <img width="12" height="12" border="0" src="/_layouts/images/blank.gif" valign="middle" class="ms-imnImg" name="imnmark" alt="No presence information" title="" id="{concat('MWP_pawn_',$ClientId,'_',$sID,',type=sip')}" sip="{$sEmail}"/>
         </a>
 </xsl:template>

This is dependant on adding a reference to the ddwrt namespace in :
xmlns:ddwrt=http://schemas.microsoft.com/WebParts/v2/DataView/runtime

And it is called and referenced like the following in ItemStyles.xsl :
<xsl:variable name="DisplayAuthor">
 <xsl:call-template name="OuterTemplate.AuthorPresence">
  <xsl:with-param name="Author" select="@Author" />
 </xsl:call-template>
</xsl:variable>            
<p>Created By:  <xsl:copy-of select="$DisplayAuthor" /></p>

References:
http://social.technet.microsoft.com/Forums/sharepoint/en-US/fb79d25c-78b7-452e-9c94-bb5e29063b0c/displaying-authors-with-presence-information-in-a-content-query-web-part-cqwp?forum=sharepointcustomizationprevious


No comments: