...

View Full Version : Clickable Sort Links



scrupul0us
05-28-2009, 06:48 PM
I have created an XSL sheet that formats an XML feed into 3 separate tables... the default sorting is done on the 'name' column

I would like to make the headings clickable links so that I can sort each table by the column I choose... I've done some googling but haven't really found what I'm looking for

I would think this would be easily done by using query string values in the links, but, I couldn't find any documentation on how to pass query string values to XSL

thanks

scrupul0us
05-28-2009, 07:52 PM
here is one of the blocks of XSL that dumps the rows of one table



<xsl:for-each select="channel/item[status='Active']">
<tr>
<xsl:attribute name="bgcolor">
<xsl:value-of select="color"/>
</xsl:attribute>
<td width="16">
<img>
<xsl:attribute name="src">
<xsl:value-of select="icon"/>
</xsl:attribute>
</img>
</td>
<td width="180">
<a>
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<xsl:value-of select="name"/>
</a>
</td>
<td align="center" width="45"><xsl:value-of select="cnt"/></td>
<td align="right" width="90"><xsl:value-of select="fm"/></td>
<td align="right" width="140"><xsl:value-of select="int"/></td>
<td align="right" width="140"></td>
<td align="right" width="70"><xsl:value-of select="run"/> Days</td>
</tr>
</xsl:for-each>



id like to be able to sort on:

name, cnt, fm, int, run

scrupul0us
05-28-2009, 08:22 PM
so if I click on


<th>
<a>
<xsl:attribute name="href"><![CDATA[?table=active&sort=run]]></xsl:attribute>Run
</a>
</th>


i can pass the value of 'sort' to:



<xsl:sort select="name"/>


and my table would b e sorted by the run column

Alex Vincent
05-29-2009, 01:04 AM
I don't think XSL has any concept of query strings, at least when run inside the browser. You'll need some script support - either server-side or JavaScript.

scrupul0us
05-29-2009, 01:40 AM
I did find this tutorial:

http://www.contentwithstyle.co.uk/content/dynamic-tables-with-xslt

which says you just have to define an xsl:param to match the name of the query string variable but I can't seem to get this working

snippet:



First thing we're going to do is to add dynamic sorting. This works using the XSL-Element <xsl:sort /> in combination with a variable. We'll insert a parameter into our XSL on top and reform the th-content in two of our collumns.

<th><a href="?smode=postcode">postcode</a></th>
<th><a href="?smode=city">city</a></th>

So now the variable “smode” will be passed to the processor. Buit we have to introduce it within the XSL as well. So within the first template we'll declare it with this line of code:

<xsl:param select="$smode"/>


i then tried to write it out by using:

<xsl:value-of select="$smode"/>

and it displays nothing

Note: I used


?table=active&sort=cnt
and
<xsl:param select="$sort"/>
and
<xsl:value-of select="$sort"/>

any ideas?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum