Sunday 7 May 2017

Linking Author Name to Profile in XSLT in Share Point 2010


How to Link Author name to profile Picture using xslt:


Recently I was working on a project and i need to link the author name to profile i.e created by name to profile in content query webparts ItemStyle in Item style.xsl

Now bellow <xsl:styleSheet tag Create parameters as bellow
<xsl:param name="PageUrl"/>
<xsl:param name="SiteUrl"/>
<xsl:param name="WebUrl"/>
PageUrl will contain the url of the page . SiteUrl will contain Url to Site. Web Url contain url to web.
you can concat SiteUrl and WebUrl to get WebUrl as below.

First declare a variable and perform a user lookup  on the account name of the user.
<xsl:variable name="authoraccount">
<xsl:value-of select="ddwrt:UserLookup(string(@Author) ,'Login')" />
</xsl:variable>
Now as we have account I can link it to sites person.aspx
 <xsl:variable name="FinalUrl">
                    <xsl:value-of  select="concat($SiteUrl,$WebUrl)"/>
   </xsl:variable>
Please Contact <a href="{$FinalUrl}/_layouts/userdisp.aspx?accountname={$authoraccount}&amp;Source={$PageUrl}"><xsl:value-of select="@Author"></xsl:value-of></a>

No comments:

Post a Comment

Setup dev environment for spfx

So lets setup dev environment for SharePoint Framework abbreviated as SPFX. for an Introduction of What is SPFX and What are the capebiliti...