Search

A new XSLT utility, "group by position" is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

@Cremol, Nice utility. Couple of questions though, the utility is currently not valid...

<xsl:apply-templates select="entry[position() mod 4 = 1]" mode="group" />

The <xsl:apply-templates/> element has to be a child of a <xsl:template/> element.

Also, the name "group items" might confuse users who are looking to group by category or something like that. Isn't this more of a "group by position" utility? Just a thought.

Thanks for your creativity and sharing this utility with us.

@bzerangue
Oops.. forgot about that... I changed it now
I find it pretty hard to describe the essence of this utility in a couple of catchy words
Group items just sounds good, but indeed might cause some confusion
I will change it 'group by position' unless someone has a better name?...

Since the name of this utility is 'group items' (for now)
I was wondering if it's possible to group items by a certain value in the entry
I am looking for something like this:

<xsl:apply-templates select="entry[category/item/@handle ='category-a']" />

This would apply the template only to the entries with a fieldname 'category' with a value of 'category-a'
It's not working at the moment, but i feel like i am pretty close... or not?

EDIT: I managed to get to the desired result by grouping the datasource by this field
But if anyone could come up with a pure xslt solution would be nice.. maybe i could implement it in this utility

@Cremol, the pure XSLT 1.0 solution would be to use the Muenchian Method.

Or you might also want to see this Grouping Page from Jeni Tennison.

Thanks, very usefull pages
I used the Muenchian Method before, and it's quit a different approach then what i was looking for in my example, which would have suited well with the 'group item by position' method
So therefore this utility will now be called 'group by position' :)

Hello Cremol,

thank you for your wonderfully helpful utility! It already works fine in my project.

Now I am trying to give every item the number of its column (for positioning with Zen Grids): Your utility puts for items in one row and then starts a news one; I want to add a class that says first/second/… item in this row. Do you know of a way to achieve this?

Thanks Moritz

Oh, I already found out: With position() I can get and use the position, either in one part of the template itself or I can forward it with a param to a subpart of the utility.

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