Search

Page and entry titles automatically get a clean handle, by the core of symphony. However I have an application here where I need to clean title nodes into url-bar usable text. I could remove redundant spaces, put all lowercase, and replace spaces and dots with hyphens, like so:

translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZ .',
                 'abcdefghijklmnopqrstuvwxyz--')

However since the app is multi language, I also would need to translate-add- all kind of special characters

Is there a more simple way of doing this?

I wonder if you could approach it from the opposite end. Rather than specifying what characters you want to remove, you could specify only characters you want to include.

Using the EXSLT str:tokenize function you can split a string into individual characters. I imagine you could then loop through each of these, and only keep those that match your string above.

To make a string URL-friendly you could also look at a urlencode() function. The EXSLT function is not supported on LibXSLT so can't be used, but I have another template bookmarked that should work: url-encode

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