I have some pages with $myparam, and some pages without it.
I'm checking the param existence with

<xsl:when test="$myparam">

but on those whithout, I get "Variable 'myparam' has not been declared".

How can I check it?


there's no way to do this with xsl, it'll always raise an error. However, xsl parameters in symphony are added as xml nodes the params node root/params. You might want to check if a node myparam exists.

I guess you're reusing/importing a template on different pages?

You can always declare an empty variable with <xsl:variable name="myparam"/> in the template where you're checking for the variable, and overwrite it with the actual value on pages where the parameter is present, like <xsl:variable name="myparam" select="/data/params/myparam"/>.

You can always declare an empty variable with in the template

And then possibly check for <xsl:when test="$myparam != ''">

An empty variable will do the trick already. No need to test for it or give a value.

@plenaforma sure, I assumed Manaus wanted to know if the param is actually set, rather than included as an empty param in order not to get an error. Not sure if that’s what he wants to achieve :)

Thanks guys,
yes @animaux, sort of if(defined($param))

@animaux you were right. @manaus good to hear it is solved

@iwyg I'm not sure, if the key is in the /data/params stack, it is checkable with <xsl:when test="$myparam">, just like $root or $workspace. I guess it's Symphony itself who brings all the /params nodes into variables, if I am right... Don't know how to reproduce the error after these months anyway.

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