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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 22:37:17
Script start
Timing: Jan 18 2025 22:37:17
Module start 'layout'
Timing: Jan 18 2025 22:37:17
Module start 'content'
Timing: Jan 18 2025 22:37:18
Module end 'content'
Timing: Jan 18 2025 22:37:18
Script end

Main resources:

Total runtime0.7796 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 589.5078152.6250
Module start 'layout' 0.00610.0025 742.132839.4453
Module start 'content' 0.00870.7691 781.5781533.0625
Module end 'content' 0.77780.0018 1,314.640612.1563
Script end 0.7796  1,326.7969 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.5062160.0002
Check MTime0.00170.2213160.0001
Mysql Total
Database connection0.00090.115710.0009
Mysqli_queries0.725693.0681570.0127
Looping result0.00060.0745550.0000
Template Total0.744895.520.3724
Template load0.00210.266120.0010
Template processing0.742795.259420.3713
Template load and register function0.00020.026310.0002
states
state_id_array0.00100.127410.0010
state_identifier_array0.00310.394920.0015
Override
Cache load0.00170.2219310.0001
Sytem overhead
Fetch class attribute can translate value0.00110.136620.0005
Fetch class attribute name0.00170.215540.0004
XML
Image XML parsing0.00060.076320.0003
class_abstraction
Instantiating content class attribute0.00000.001740.0000
General
dbfile0.00080.1056160.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs