I'm trying to create a carousel presentation of list items as "slides" using a DataFormWebPart. I've set the Data View's paging to Display sets of 1 item. I've pulled as much of the mucky tables from the code as I could, and replaced the stock paging icons, and it displays and advances to the next list item properly.
The issue I've encountered is the with the "previous set" action that, when it works, would display the list item previous the currently displayed item. When clicked, the entire page is sent "back" as if I'd clicked the browser's back button.
Here's what I believe is the relevant template sections...
<xsl:template name="dvt_1.navigation">
<xsl:param name="FirstRow" />
<xsl:param name="LastRow" />
<xsl:param name="RowLimit" />
<xsl:param name="dvt_RowCount" />
<xsl:param name="RealLastRow" />
<xsl:variable name="PrevRow">
<xsl:choose>
<xsl:when test="$FirstRow - $RowLimit < 1">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$FirstRow - $RowLimit" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="LastRowValue">
<xsl:choose>
<xsl:when test="$LastRow > $RealLastRow">
<xsl:value-of select="$LastRow"></xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$RealLastRow"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="NextRow">
<xsl:value-of select="$LastRowValue + 1"></xsl:value-of>
</xsl:variable>
<xsl:if test="$dvt_firstrow > 1" ddwrt:cf_ignore="1">
<a>
<xsl:attribute name="href">javascript: history.back();</xsl:attribute>
<img src="/gmcc/assets/ui/carousel_left.png" border="0" alt="Previous" />
</a>
</xsl:if>
<xsl:if test="$LastRowValue < $dvt_RowCount or string-length($dvt_nextpagedata)!=0" ddwrt:cf_ignore="1">
<a>
<xsl:attribute name="href">
javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$NextRow,'};dvt_startposition={',$dvt_nextpagedata,'}'))" />;
</xsl:attribute>
<img src="/gmcc/assets/ui/carousel_right.png" border="0" alt="Next" />
</a>
</xsl:if>
And I've isolated the code for the paging controls:
<xsl:if test="$dvt_firstrow > 1" ddwrt:cf_ignore="1">
<a>
<xsl:attribute name="href">javascript: history.back();</xsl:attribute>
<img src="/gmcc/assets/ui/carousel_left.png" border="0" alt="Previous" />
</a>
</xsl:if>
<xsl:if test="$LastRowValue < $dvt_RowCount or string-length($dvt_nextpagedata)!=0" ddwrt:cf_ignore="1">
<a>
<xsl:attribute name="href">
javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$NextRow,'};dvt_startposition={',$dvt_nextpagedata,'}'))" />;
</xsl:attribute>
<img src="/gmcc/assets/ui/carousel_right.png" border="0" alt="Next" />
</a>
It uses an if
statement and applies a javascript action based on the outcome. I'm not savvy in XML/XSLT to know if I can correct the issue by editing the if
statement, but I can see that the "back" javascript is a simple javascript: history.back();
, whereas the "next" is a more complicated javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$NextRow,'};dvt_startposition={',$dvt_nextpagedata,'}'))" />;
I've tried some guesses as to how I can copy, then modify, the "next" code to create antonymous "previous" code, but I can't seem to figure out what I need, either in the JavaScript or the XSLT. I want clicking the left bracket to display the previous list item, and I'm stuck.