0

Let's say I have a simple text column named MyCustomName with four fields in it:

REMOVE one
REMOVE two
three
REMOVE four

...and I want them to display like

one
two
three
four

in my list View. In order to do that I edit the View's XSLT code and come up with the following template:

<xsl:template name="FieldRef_Text_body.MyCustomName" ddwrt:dvt_mode="body" match ="FieldRef[@Name='MyCustomName']" mode="Text_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:choose>
        <xsl:when test="@AutoHyperLink='TRUE'">
            <span>
                <xsl:if test="contains($thisNode/@MyCustomName, 'REMOVE')" ddwrt:cf_explicit="1">
                    <xsl:value-of select="concat(substring-before($thisNode/@MyCustomName, 'REMOVE'), substring-after($thisNode/@MyCustomName, 'REMOVE'))" disable-output-escaping="yes" />
                </xsl:if>
                <xsl:if test="not(contains($thisNode/@MyCustomName, 'REMOVE'))" ddwrt:cf_explicit="1">
                    <xsl:value-of select="$thisNode/@*[name()=current()/@Name]"/>
                </xsl:if>
            </span>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="$thisNode/@*[name()=current()/@Name]"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

Now this works fine and my elements get rendered as I intended. However, what if the column is not a simple Text Column but a Lookup Column? My code doesn't seem to work in that case, what do I need to change?

1 Answer 1

0

Did it a bit differently and finally it works, code if anybody had similar problem:

<xsl:template match="FieldRef[(@Encoded) and @Name='MyCustomColumn']" priority="10" ddwrt:dvt_mode="body" mode="Lookup_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:if test="contains(normalize-space($thisNode/@MyCustomColumn), 'REMOVE')" ddwrt:cf_explicit="1">
        <xsl:value-of select="concat(substring-before($thisNode/@*[name()=current()/@Name], 'REMOVE'), substring-after($thisNode/@*[name()=current()/@Name], 'REMOVE'))" disable-output-escaping="yes" />
    </xsl:if>
    <xsl:if test="not(contains(normalize-space($thisNode/@MyCustomColumn), 'REMOVE'))" ddwrt:cf_explicit="1">
        <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" />
    </xsl:if>
</xsl:template>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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