Search

I’m doing the following in my xsl template

<xsl:if test="@handle = $current-page and not($page)">

Which, if the parameter isn’t available (as it is a url parameter) get the following error

XSLTProcessor::transformToXml(): Variable 'page' has not been declared.

What I’m trying to do with the if statement is to see whether the $page parameter is not set, i.e. null. The error is being thrown as on some pages, the $page parameter is not even declared as it isn’t an url parameter for that page.

Does anyone know how I should write this if statement correctly? It’s probably really simple, I haven’t slept in 24hrs…

XSLT doesn’t like it if you check for variables/params that don’t exist. You need to add a blank fallback variable somewhere in your template stylesheet (outside the template):

<xsl:variable name="page"/>

I think what I’m after is some kind of isset() function like in PHP. I need to achieve the following:

if $handle is equal to $current-page and if $page parameter exists, check that it has no value

Is this possible?

Oh, missed that! Cheers!

Yep, it fixed it, thanks @makenosound…

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