A new Extension, “URL Segments” 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.

Sometimes I like to have access to each part of the URL—Expression Engine style—URL segments outputs each part of the URL, excluding the $root as params for use in XSL and data-source filtering. For example:

Would be output as:

$url-segment-1 = 'about'
$url-segment-2 = 'contact'

It makes matching params on nested page structures a little easier, available now on the Github.

It would be convenient if it also had a $url-segment-active

Currently achieving this in xslt with the params this extension supplies is still more complex then:

<xsl:variable name="lastlevel">
<!-- active url param as variable -->
    <xsl:when test="$level4 != ''">
        <xsl:value-of select="$level4"/>
    <xsl:when test="$level3 != ''">
        <xsl:value-of select="$level3"/>
    <xsl:when test="$level2 != ''">
        <xsl:value-of select="$level2"/>

Sure, I had that in another project but I took it out because I didn’t need it. How about it includes a $url-segment-active and a $url-segment-last where active is the index and last is it’s value?

You could perhaps also include a datasource that outputs them as an XML element, making it much easier to loop over the page parameters.

I just created a Param Pool to XML extension for another project, which should help here. It converts the param pool arrays into XML for consumption in your Page. This means you can loop over specific nodes should you wish:

There are <xsl:value-of select="count(/data/param-pool/*[starts-with(name(),'url-segment-')])"/> URL segments.

@newnomad: I’ve pushed an update to the extension that implements the $url-segment-active and $url-segment-last param. I’ve also included a data-source as per Rowan’s suggestion with the following format:

<url-segments last="contact" active="2">

The data-source is basically a limited implementation of the Param Pool to XML that Nick’s put together.

@makenosound Max, I started using this yesterday and it really handy. Thanks for making it available.

Works for me in 2.2.1 Cheers!

This extension is going to be really useful to implement a Taxonomy system. Thanks @Makenosound for developing it! ;)

Some day I will understand what Taxonomy means.

Taxonomy == categories, classification and order :-)

Huuu, that sounds rather abstract.

Huuu, that sounds rather abstract.

You can think of it as a way to build hierarchies :)

I should have learned something useful. I hope that you will give me an example at the "Sümposium" in Germany!

It's origins are from hierarchically categorizing all the species and plants (from the Greek taxis meaning order).

mr smartypants

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