Search

Hello.

I got two sections (well, three, but the third “Language keys” does not involve in this problem) and a “Navigation” DS as described below:

Section keys {
  Key             (Text Input Field)   # "Navigation" @handle
  Sequence number (Text Input Field limited to numbers only)
}

# Translations
Sections {
  For     (Select Box Link for "Section Keys / Key")
  In      (Select Box Link for "Language Keys / Key")   # not involved
  Value   (Text Input Field)
}

I created XSLT to go through “Navigation” replacing the section names by proper translated section names (I used “Recursive Navigation” XSLT utility as my starting point). I works just fine. The problem is I do not know to sort the “Navigation” by the “Section keys / Sequence number” to keep the navigation statically sorted the way I need it to appear on the website. Any ideas? This is, I hope, one of the last problems I got to create my fully multi-lingual website.

Have you tried using the <xsl:sort /> element with your <xsl:apply-templates />, if that’s what you use?

Sample data I need produce navigation list sorted by “Sequence number” with translations by “Sections” entries for some “$url-hl” containg the language code. I really do not know how to produce it. Does xsl:sort help in this case? I use xsl:call-template. Here is the XSLT code. The only thing I need to add is sorting by the “Sequence numbers”.

I have got an petite idea. What if I used xsl:copy-of and combined all the three involving sections together? I mean what if I combined “Sections”, “Navigation” and “Sections keys” together at first, then I could xsl:sort them by any field I like? What do you mean? Isn’t it overkill? I mean, if there was some simpler way…

You provided your XSLT above. It would make it easier for someone to help if you also posted all the XML that is relevant.

I think since they are different node sets I would apply-templates on the section keys using xsl:sort for sorting by the sequence number. Then you’d call-template or apply-template on what you really want to output, based on the current sequence number.

But if the section keys does not represent the hierarchy of the pages in any way this will be very tricky.

It’s a bit of a complex solution, and I haven’t quite wrapped my mind around all the pieces of it…

Here is the full XML.

@froded: Indeed, the “Section keys” has nothing to do with the real hierarchy. It’s main purpose is to maintain “keys” for translations of section names and the “Sequence numbers” for the sorting/ordering of the translated section names, because it’s clear such data like the navigational data can not be sorted by DS (very likely resulting in unwanted order). Such sort of data simply must be “pre-sorted”, thus the existence of the “Sequence numbers”.

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