maandag 12 november 2012

XSL template to obtain all visible fields in Content Query WebPart

When we are editing XSLT for Content Query WebPart, XSLTListViewWebPart or any other WebPart with configurable XSLT, you can obtain all list fields and their values with following template:
<xsl:template name="ShowXML" match="Row[@Style='ShowXML']" mode="itemstyle">
    <xsl:variable name="SafeLinkUrl">
      <xsl:call-template name="OuterTemplate.GetSafeLink">
        <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
    <xsl:variable name="DisplayTitle">
      <xsl:call-template name="OuterTemplate.GetTitle">
        <xsl:with-param name="Title" select="@Title"/>
        <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
      Item: <i>
        <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
          <xsl:value-of select="$DisplayTitle"/>
      <xsl:for-each select="@*">
        <xsl:sort select="name()"/>
          <xsl:value-of select="name()" />
          <xsl:text disable-output-escaping="yes"> </xsl:text>
            <xsl:value-of select="."/>
    <br />

Notice that @ is the beginning char of any list field.

Geen opmerkingen:

Een reactie posten