Friday, July 12, 2013

Pagelet Wizard - format dates

To format the dates you can use the PSFORMAT tag.

The tricky bit is working out where to apply the new tag, as the documentation (here and here) is unclear.

Look for the bit that says this. This is where it reads the results of the Query.
<xsl:template match="/queryresult/queryrows/row">

Then it will start to do the columns for each one and reference the xsl value-of command. e.g.
So if your date column is the fourth one in the query look for the 4th TD tag.
Surrounding the value of use the PSFORMAT tag. For example
      <td>
        <xsl:variable name="style4">
          <xsl:call-template name="cellthreshold">
            <xsl:with-param name="column_id" select="querydata[position()=4]/@fieldname"/>
            <xsl:with-param name="thisvalue" select="querydata[position()=4]/text"/>
            <xsl:with-param name="rowstyle" select="$rowstyle"/>
            <xsl:with-param name="rowstylepos" select="$rowstylepos"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:if test="not(starts-with($style4,';'))">
          <xsl:attribute name="style">
            <xsl:value-of select="$style4"/>
          </xsl:attribute>
        </xsl:if>
        <PSFORMAT TYPE="DATE" FORMAT="dd/MM/y" FORMAT_DEU="dd.MM.y">
          <xsl:value-of select="querydata[position()=4]/text"/>
        </PSFORMAT>
      </td>

I am pretty sure that the "position()=n" refers to the actual column in the query, so if the query columns are different to the pagelet wizard columns amend the number..