ez.no / exponential / documentation / customization / tips & tricks / how can i use my own php script inside ezp?
These documentation pages are no longer maintained. Please visit the new documentation site.
eZp can't use PHP code inside templates, however there is a way to use your own PHP scripts in a template:
First include your PHP script inside eZp's index.php. Let's assume your PHP script is divided in three, input-handling, data-handling and output generation.
eZp corrects all $GLOBALS, _GET and _POST for magic quotes for safety reasons. More info in ./lib/ezutils/classes/ezsys.php
Just echo-ing the variables is not enough! Since eZp is run from one script source, index.php, you'll have to add a way to execute a script based on the URL tags.
Data handling of your scripts should be no problem at all, except when both your script and eZp use the same variable names. If that's the case, start renaming of your scripts variables.
The trick is to put all output of your script in a $variable. Some scripts use a (customized) template engine and there might be an option for output into a $variable instead of the screen. This is achieved with output buffering, for more information see ob_start -- Turn on output buffering.
ob_start(); # start output buffering # put your output script here $variable = ob_get_contents(); # store the output in $variable ob_end_clean(); # clean output buffering
All output is now in $variable !
The last step is to include this into your eZp template:
{$variable}
Notes:
Subversion 2019 contains a file calles ezphpcreator.php in ./lib/ezutils/classes. Comments or SDK references are not included but it looks like a PHP implementation by eZp!
Comments
Another solution to using PHP inside templates
Mark Overduin
Monday 25 August 2003 1:27:04 pm
http://ez.no/developer/exponential...cks/including_php_files_in_templates