How-to: php script inside tpl file?

Author Message

Alessandro Cipriani

Friday 27 February 2004 12:57:30 am

hi all
as you can read in http://ez.no/community/forum/setup_design/how_to_retrieve_session_id, i need to retrieve session id in my homepage.
with ezhttp i didn't be able to retrieve the id, so my question is the follow:

i think that i can insert some php script into the tpl page (<?php ... ?>). but how?
if i write
<?php
session_start();
$sid = session_id(); echo sid;
echo 'Hello world';
?>
either sid, either 'Hello world' aren't displayed! so i think is a php syntax error...

any hint?
best regards
alessandro
no output is displayed

Alex Jones

Friday 27 February 2004 6:15:28 am

Alessandro, I am afraid there is not an easy way to include PHP inside of a template. This was a choice that the eZ team specifically made. What you should do is build an operator that includes the PHP you need access to. Check out http://ez.no/ez_publish/documentation/development/kernel/custom_template_operators and perhaps search for 'operators' on the ez.no site for more information.

Alex

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

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

Alessandro Cipriani

Friday 27 February 2004 6:37:21 am

thanx alex
i think that another way to solve my problem would be use ezhttp to retrieve the session id... isn't it possible?

best regards
alessandro

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:20:05
Script start
Timing: Jan 18 2025 22:20:05
Module start 'layout'
Timing: Jan 18 2025 22:20:05
Module start 'content'
Timing: Jan 18 2025 22:20:06
Module end 'content'
Timing: Jan 18 2025 22:20:06
Script end

Main resources:

Total runtime1.2169 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.0047 589.0703152.6250
Module start 'layout' 0.00470.0021 741.695339.4453
Module start 'content' 0.00681.2086 781.1406541.2813
Module end 'content' 1.21550.0014 1,322.421912.1563
Script end 1.2169  1,334.5781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00290.2391160.0002
Check MTime0.00120.0997160.0001
Mysql Total
Database connection0.00090.070810.0009
Mysqli_queries1.174696.5191570.0206
Looping result0.00040.0323550.0000
Template Total1.190297.820.5951
Template load0.00180.151420.0009
Template processing1.188397.648620.5941
Template load and register function0.00010.006910.0001
states
state_id_array0.00130.104210.0013
state_identifier_array0.00140.112120.0007
Override
Cache load0.00150.1255290.0001
Sytem overhead
Fetch class attribute can translate value0.00040.034320.0002
Fetch class attribute name0.00080.069350.0002
XML
Image XML parsing0.00110.087220.0005
class_abstraction
Instantiating content class attribute0.00000.000760.0000
General
dbfile0.00090.0731220.0000
String conversion0.00000.000440.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/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs