eZ Community » Forums » eZ Publish 5 Platform » Custom tag and php function
expandshrink

Custom tag and php function

Custom tag and php function

Tuesday 03 February 2015 3:45:25 pm - 5 replies

Hei,

Does anyone has an example of  using XSLTProcessor for calling php functions in custom tag?
I try to get the content of a node from a ID that comes from content...

Here is the documentation but it just says that it s possible without giving an example
https://doc.ez.no/display/EZP/How+to+implement+a+Custom+Tag+for+XMLText+FieldType

 

thanx!

Tuesday 03 February 2015 4:32:02 pm

Hi

You need to implement a pre-converter for this. See EmbedTagBundle implementation for an example.

Tuesday 03 February 2015 4:37:34 pm

Hi Daniel,

this is PHP feature, documented here: http://php.net/manual/en/xsltprocessor.registerphpfunctions.php

Don't forget to add xmlns:php="http://php.net/xsl" to xsl:stylesheet element in your transformation.

Wednesday 04 February 2015 9:45:11 am

Thanx guys!

I understand if I want to use custom functions I can't use XSLTProcessor but EmbedTagBundle?

I'll give a try to both, always nice learning new things.

Cheers!

Wednesday 04 February 2015 10:53:37 am

Quote from Daniel Gracia :

I understand if I want to use custom functions I can't use XSLTProcessor but EmbedTagBundle?

You are free to use EmbedTagBundle or any other bundle, but that was not what we tried to tell you. I have updated the doc a bit, it should be a bit more clear now.

Basically if you want to write your own custom tag with dynamic functionality, and there is no existing solution (bundle) to your specific problem, then you can either use PHP functions in XSLT for simple use cases, or if you need other services like Repository, then you need to use a Pre-Converter as explained in the doc.  EmbedTagBundle is an example of the latter (Pre-converter).

Wednesday 04 February 2015 11:45:15 am

EmbedTagBundle is just an implementation example... You need to implement your own stuff.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from