Forums / General / How to include PHP-script in ez?

How to include PHP-script in ez?

Author Message

Harald Svendsen

Tuesday 02 December 2003 4:19:03 am

Hello

I would like to use some php-code in pagelayout.tpl. To do this I have to write the code in index.php and then kind of print the result in pagelayout.tpl. I've tried to do as this guide describes: http://ezwiki.blanko.info/index.php/3XHT_UsePHP

I've added the following code in index.php:
ob_start();
echo "This is a test";
$test1 = ob_get_contents();
ob_end_clean();

In pagelayout.tpl:
{$test1}

Result: I get no output.

What have I done wrong?

Thanks in advance!

Harald

Alex Jones

Tuesday 02 December 2003 2:19:28 pm

I'm not sure what is wrong, but you may want to take a look at http://ez.no/developer/ez_publish_3/documentation/customization/tips_tricks/including_php_files_in_templates

Perhaps it can help get you back on track.

Also, you may want to look at creating your own operator which is the prefered method. More information about: http://ez.no/developer/ez_publish_3/documentation/development/kernel/custom_template_operators

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Harald Svendsen

Wednesday 03 December 2003 6:09:58 am

Now I get output by doing the following:
put these lines between the ob_start() and eZDebug::addTimingPoint( "END" ); in index.php:

echo "This is a test";
$test1 = ob_get_contents();

But the text "This is a test" gets printed at the top of the page, no matter where I put the {$test1} in pagelayout.tpl.

What happens is that echo "This is a test" displays the text on the webpage, but the $test1 shows nothing.

Any suggestions?

Harald