Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Salvete! In my list, I have a column formatted as a Number, titled, say, "My Number", and the actual markup name of the column is "My_Number".

Now, I want to convert the entire column, in any list, into a hyperlink, so that the link becomes something like "My Number"

I have read here and here, and Microsoft's page, too, that this might be accomplished with xslt, but even after an iis reset, I can't seem to change the field values into the links that I want. Here is my custom fldtypes_MyNumber.xsl, which is placed in the /_layouts/XSL directory:

<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">

<xsl:template match="FieldRef[@Name='My_Number']" >
    <xsl:param name="thisNode" select="."/>
    <a target="_blank" href="/mypages/mysite{$thisNode/@My_Number}">{$thisNode/@My_Number}</a>
</xsl:template>

So what do I do to get this to work?

[UPDATE]

I changed mode=Number to mode=Number_body and now the hyperlink is generated and inserted properly! However, the hyperlink text label is rendered literally... How do I use the text that was originally there as a variable?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Got it! It was a matter of manipulating xsl markup in the right fashion. Here is the final result. It transforms an ordinary number in a Number column into a hyperlink.

<xsl:template match="FieldRef[@Name='My_Number']" mode="Number_body">
<xsl:param name="thisNode" select="."/>
    <a target="_blank">
    <xsl:attribute name="href">/mypages/mysite<xsl:value-of select="$thisNode/@My_Number"/></xsl:attribute>
    <xsl:value-of select="$thisNode/@My_Number" />
    </a>
</xsl:template>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.