0 users online. Create an account or sign in to join them.Users

Search

One other nice usecase is to convert images via base64_encode() into a string representation. This way you can export entries via XML with embedded images. :-)

How do i use native php functions?

I've already successfully made an extension with a custom php function. So i can call my function using custom_func:func_name($string).

If they are native php functions, then use the php: namespace for the function.

Do i have to declare them first? How do i do that?

I'm trying php:str_replace(arguments) but it get an error: function rstr_replace not found. Unregistered function

Is the *r*str_replace in

function rstr_replace not found. Unregistered function

a typo just in your post or in your XSL?

Sorry! A typo in my post.

I've included this line: <xsl:include href='efm://functions' /> (and the php namespace) and used the function like this: <xsl:value-of select="php:str_replace('[[','bbbb','aaaa[[cccc')"/>

But i get the error: xmlXPathCompOpEval: function str_replace not found. Unregistered function

Tried changing the php xmlns to xmlns:php="http://php.net/xsl" (found in exsl_function_manager/lib/class.functionstream.php) and still cannot get it to work!

I can't get the example to work. hello() works, but hellonode() doesn't.

This code works:

<xsl:variable name="name" select="'I am a boring string.'" />
<p><xsl:value-of select="my_function:hello($name)" /></p>

But this code causes the page to not render (blank page):

<xsl:variable name="testnode">
    <node>Hello, I'm a node. I've been to PHP and back. Wild stuff.</node>
</xsl:variable>
<xsl:copy-of select="my_function:hellonode($testnode)" />

Sorry! A typo in my post. I've included this line: (and the php namespace) and used the >function like this: But i get the error: xmlXPathCompOpEval: function str_replace not found. Unregistered function

I have same issue, does anyone knows how to deal with this problem?

With a small addition to EXSL Function Manager, PHP native functions can be made to work.

In the file extension.driver.php there is the following function:

public function initFunctionManager($context){
    $Manager = new FunctionManager($context);
    $Manager->createDelegate();
    $Manager->createStream();
}

Make it like this:

public function initFunctionManager($context){
    $Manager = new FunctionManager($context);
    $Manager->createDelegate();
    $Manager->createStream();
    $context['page']->registerPHPFunction(get_defined_functions()['internal']);
}

Alternatively, instead of registering all 700+ native functions, an array of function names can be used like so:

$context['page']->registerPHPFunction(array('str_replace', 'whatever_else'));

Using PHP in XSL is done as in this example:

<xsl:value-of select="php:functionString('str_replace', '[[', 'bbbb', 'aaaa[[cccc')"/>

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3, 5.4, 5.5 or 5.6
  • 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