Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Clickable Sort Links

    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
    IF I DID GOOD THROW ME A REP POINT

  • #2
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts
    here is one of the blocks of XSL that dumps the rows of one table

    Code:
    <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
    IF I DID GOOD THROW ME A REP POINT

  • #3
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts
    so if I click on
    Code:
    <th>
    	<a>
    	<xsl:attribute name="href"><![CDATA[?table=active&sort=run]]></xsl:attribute>Run
    	</a>
    </th>
    i can pass the value of 'sort' to:

    Code:
    <xsl:sort select="name"/>
    and my table would b e sorted by the run column
    IF I DID GOOD THROW ME A REP POINT

  • #4
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    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.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #5
    Regular Coder
    Join Date
    Sep 2004
    Posts
    230
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I did find this tutorial:

    http://www.contentwithstyle.co.uk/co...bles-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:

    Code:
     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
    Code:
    ?table=active&sort=cnt
    and
    <xsl:param select="$sort"/> 
    and
    <xsl:value-of select="$sort"/>
    any ideas?
    Last edited by scrupul0us; 05-29-2009 at 02:45 AM.
    IF I DID GOOD THROW ME A REP POINT


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •