Search

I've been trying to figure out a simply way to have XSLT automatically add the year to my footer. No go so I'm resorting to PHP. However, it seems that's not going to be easy either as just putting PHP into my XSLT template doesn't work.

I had a similar problem with javascript before and had to resort to using only external scripts and cutting some features completely.

It's seemingly simple thing I wish to achieve. I'm hoping to replicate which simply gets the current year from the server.

Is there an XSLT equivalent or a way to embed other languages, namely PHP or javascript, in an XSLT template?

as far as i understand

 <xsl:value-of select="$this-year"/>

should do the job...

Doug, when you append ?debug to the end of your pages to check the XML, click on the "Params" link on the right. It will show you all available parameters that Symphony makes available to use in your XSLT.

I see that but I'm rather new to XSLT and not really sure how to pull in one of those params. I tried doing it like I would do any node but that didn't seem to work too well. Any tips?

@Roman: I gave that a shot and it threw up a few errors.

Maybe post those errors?

Errors are as follows:

XSL processing error: process(): xmlXPathCompiledEval: evaluation failed

XSL processing error: resultdumpmem() expects parameter 1 to be object, boolean given

That being said, a bit of playing around with what you'd given me and I came up with this, which works: <xsl:value-of select="substring-before($today,'-')"/>

@doug, that's strange that Roman's suggestion is giving you errors. I was looking at the ?debug page in the Params link and this is what I see:

Debug Params

If you are seeing the same params, then Roman's suggestion shouldn't be throwing any errors.

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