Im currently customising the CoreResultsWebPart and using it to aggregate Blog posts. One of the default fields it returns is the Author field. The author field though, is crawled and displayed as the Display name of the user. Eg:
A users login name is 'mydomain\john.smith'
Their display name is 'John Smith'
Core results returns 'John Smith'.
I need to get the users login name so I can call a custom function in my xsl 'GetUserProfilePicture(string loginName)' to get the user's profile picture to be shown alongside their blog post summary.
This is the xml output from the search result...
<all_results>
<result>
<id>3</id>
<workid>96</workid>
<rank>100000000</rank>
<username></username>
<title>What a great post by sp user 1!</title>
<author_multival>S.P. User 1</author_multival>
<author>S.P. User 1</author>
<size>0</size>
<url>http://myintranet/blog/Lists/Posts/ViewPost.aspx?ID=3</url>
<urlencoded>http%3A%2F%2Fmyintranet%2Fblog%2FLists%2FPosts%2FViewPost%2Easpx%3FID%3D3</urlencoded>
<description></description>
<write>3/15/2013</write>
<sitename>http://myintranet/blog/Lists/Posts</sitename>
<collapsingstatus>0</collapsingstatus>
<hithighlightedsummary>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto <ddd> </ddd>
</hithighlightedsummary>
<hithighlightedproperties>
<hhtitle>What a great post by sp user 1!</hhtitle>
<hhurl>http://myintranet/blog/Lists/Posts/ViewPost.aspx?ID=3</hhurl>
</hithighlightedproperties>
<contentclass>STS_ListItem_Posts</contentclass>
<isdocument>False</isdocument>
<picturethumbnailurl></picturethumbnailurl>
<serverredirectedurl></serverredirectedurl>
<fileextension>ASPX</fileextension>
<ows_metadatafacetinfo></ows_metadatafacetinfo>
<popularsocialtags>
<imageurl imageurldescription="List Item">/_layouts/images/STS_ListItem16.gif</imageurl>
</popularsocialtags>
</result>
<totalresults>3</totalresults>
<numberofresults>3</numberofresults>
</all_results>
As you can see above, the author is showing the display name. Below is the code I want to run...
<xsl:variable name="user" select="author"/>
<img align="absmiddle" src="{customxsl:GetUserProfilePictureURL($user)}" border="0" alt="Blog" />
public string GetUserProfilePictureURL(string username)
{
string Url = string.Empty;
if (!String.IsNullOrEmpty(username))
{
if (upm.UserExists(username))
{
UserProfile profile = upm.GetUserProfile(username);
if (profile != null)
{
Url = profile["PictureURL"].Value.ToString();
}
}
}
if (string.IsNullOrEmpty(Url))
Url = "/_layouts/images/O14_person_placeHolder_96.png";
return Url;
}
Anyone know how I can get the login name of the author? Any magic managed properties?