Search

Hey ninjas -

I’m creating a page on a site that is going to use several sorting and search options. Rather than create a separate data source for every single sorting option, which can also be combined with a url parameter to sort under a specific criteria, I’m using some conditionals with xsl:sort. Unfortunately, as I found out and most of you probably know, you’re not allowed to use xsl:sort as a child of xsl:if. This requires a lot of repetitive coding.

I was hoping perhaps someone had a better suggestion? A bit of googling made it appear that going against DRY was probably the only way. This is my first experience with a functional language, so don’t judge too harshly :)

pastebin

Hi fawx, there might be another way you can write this. Here’s my attempt, although not entirely sure it does exactly what you need (I might have missed something subtle):

http://gist.github.com/433291

My code might not work out of the box — you may need to use EXSLT to cast $entries into a nodeset for it to work:

exsl:node-set($entries)

(After importing the EXSLT common namespace.)

Might put you in a different direction…

thanks, nick. that actually is a huge help. i had forgotten about the ability to store a node set in a variable.

edit: i’ve completely missed out on the potential that storing node sets in variables offers in a lot of my projects. this is game-changing for me. thanks again.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details