SharePoint 2010 Remove link from people or person column in XSLT

i already posted about the possibility to remove the hyperlinks from a column in XSLT in for example a data view webpart or a listview webpart. In this post i used a special xsl



//use this
<xsl:value -of select="substring-after($thisNode/@*[name()=concat(current()/@Name,'.')], '#')"  disable-output-escaping="yes"/>

//or use this from my old post
<xsl:value -of select=”substring-before(substring-after(@MyColumn, ‘&amp;gt;’), ‘&amp;lt;’)” disable-output-escaping=”yes”/>


The first works fine for lookup columns which has a link to its item display menu. The second one is if a hyperlink column is used. But what if you have a column or field from type people or person? In this case you have to do one step more and work with a variable as below:



<xsl:variable name="UserName" select="$thisNode/@MyColumn"/>
<xsl:value -of select="substring-after(substring-before(substring-after($UserName,'ID='),'&amp;lt;'),'&amp;gt;')" />


This worked great for me, cause it displays the username as same as before but without the hyperlink. So its result is not someting like domain\username but User Name. But please be informed that i only displays the first value! That means, if you use a field from type user and you check the option to multiple values it won’t show more than one person name. If you need to ensure that all persons are displayed you should change the delimiter to your needs.

Hope this helps you.

..:: I LIKE SHAREPOINT ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.