Search

Hi,

I want to make filter based on 'mn' and 'y'. This code renders all entries in one column (no filters). I have no idea how to solve this problem...

XML & XSL:

E.g.

I have 3 entries with mn='January' and y='2015', and 2 entries with mn='February' and y='2015'.

For every 'mn' and 'y' do a loop. I also would like to make that loop working for new entries.

Thanks for any suggestion :)

I have 3 entries with mn='January' and y='2015', and 2 entries with mn='February' and y='2015'.

For these entries, what is the desired output?

Sample output

Grouping using Muenchian method is your friend. Following code is not even compiled :)

<xsl:key name="entries-by-year" match="/data/se/entry" use="y" />
<xsl:key name="entries-by-month" match="/data/se/entry" use="mn" />

<xsl:template match="/">

   <!-- For all entries, find unique years descending; traverse entries for each year -->
   <xsl:for-each select="data/se/entry[count(. | key('entries-by-year', y)[1]) = 1]">
      <xsl:sort select="y" dir="descending" />

      <h1>
         <xsl:value-of select="y"/>
      <h1>

      <!-- For entries in this year, find unique months, descending; traverse entries for each month -->
      <xsl:for-each select="key('entries-by-year', y)[count(. | key('entries-by-month', mn)[1]) = 1]">
         <xsl:sort select="mn" dir="descending"/>

         <h2>
            <xsl:value-of select="mn"/>
         </h2>

         <!-- For entries in this month -->
         <xsl:for-each select="key('entries-by-month', mn)">
            <h3>
               <xsl:value-of select="et"/>
            </h3>

            <xsl:copy-of select="p"/>
         </xsl:for-each>

      </xsl:for-each>

   </xsl:for-each>

</xsl:template>

I'm eagger to know if above works. Never made a double grouping before.

Thanks, I will let you know if it works.

OK, I made it :)

Excelent :D

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