2

I've got a custom function say <?php this_content('Main heading'); ?> and I want to add inside my xsl, which looks like this:

<xsl:template match="page" mode="body">

</xsl:template>

I've set registerPHPFunctions(), but thats only for php internal functions..?

1
  • Have you configured Apache (or your webserver) to have PHP process .xsl files? Commented Feb 4, 2011 at 5:11

1 Answer 1

6

No, it works for functions you've defined, too. Make sure that you've added the php namespace to your opening XSL tag as below:

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:php="http://php.net/xsl">

Then you can call your PHP functions using php:function('function_name', ...).

(You can't just embed blocks of PHP code like you would in a .php file.)

See the examples and comments on the PHP man page for registerPHPFunctions() for more info.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.