How to execute code inside templates?

Author Message

Francisco Felix

Friday 25 July 2003 1:45:12 pm

As I need this for change the design inserting external funcionality I posted this message first in the design forum, but I think this is a more suitable place. Sorry, it wont happen again.

I need to executePHP code directly inside templates in order to include external funcionality, for example our poll system or our banner ad server. I made tests and the PHP code come out as is when I included it in the template.

It seems that expanding PHP with specific functions and then writing our own template operator ( http://www.ez.no/developer/ez_publish_3/documentation/development/kernel/custom_template_operators ) would do it, but this method has big disadvantages.

I think tweaking the template rendering system would be sufficient to allow execution of PHP inside them and thus solving the problem, but right now I dont have the knowledge about the EZPublish system to do this and cant find that knowledge in the documentation either.

I have tried to understand the code from reading it (as EZPublish team suggests) but I have not that kind of talent.

Any help or tougths will be appreciated.

Alex Jones

Friday 25 July 2003 1:47:43 pm

You may want to check out this thread (http://ez.no/developer/ez_publish_3/forum/general/php_support_in_templates) as the idea of PHP within templates is discussed by several of us, including the folks at eZ systems.

Alex

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

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

Francisco Felix

Friday 25 July 2003 2:09:15 pm

Thanks a lot, a lot really for pointing that out Alex. I am already cheking it out and would continue at there.

What a fast response, what a community. You can bet that when I learn I will be here sharing with you all.

Alex Jones

Friday 25 July 2003 2:13:05 pm

Glad to hear it! I am still coming up to speed as the learning curve can be steep. But so far it hs proven quite worthwhile.

The more of us helping each other, the better of we will all be.

Alex

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

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

Francisco Felix

Friday 25 July 2003 2:21:51 pm

Check http://ez.no/developer/ez_publish_3/documentation/customization/tips_tricks/including_php_files_in_templates

Jan Borsodi

Saturday 26 July 2003 4:11:52 am

I've added a suggestion on how code execution could be done, feel free to comment on it.
http://ez.no/developer/ez_publish_3/forum/suggestions/php_execution_in_templates

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

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 19:07:42
Script start
Timing: Jan 18 2025 19:07:42
Module start 'layout'
Timing: Jan 18 2025 19:07:42
Module start 'content'
Timing: Jan 18 2025 19:07:43
Module end 'content'
Timing: Jan 18 2025 19:07:43
Script end

Main resources:

Total runtime0.7649 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 587.9375152.6250
Module start 'layout' 0.00720.0040 740.562539.4453
Module start 'content' 0.01120.7522 780.0078602.7656
Module end 'content' 0.76340.0015 1,382.773416.1563
Script end 0.7648  1,398.9297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.5733160.0003
Check MTime0.00220.2875160.0001
Mysql Total
Database connection0.00090.112710.0009
Mysqli_queries0.700391.5549680.0103
Looping result0.00080.0991660.0000
Template Total0.716893.720.3584
Template load0.00320.423620.0016
Template processing0.713593.284420.3568
Template load and register function0.00020.020110.0002
states
state_id_array0.00180.231910.0018
state_identifier_array0.00290.385120.0015
Override
Cache load0.00290.3764270.0001
Sytem overhead
Fetch class attribute can translate value0.00060.082930.0002
Fetch class attribute name0.00220.294180.0003
XML
Image XML parsing0.00140.181830.0005
class_abstraction
Instantiating content class attribute0.00000.005690.0000
General
dbfile0.00100.1242230.0000
String conversion0.00000.001140.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
6content/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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs