Forums / Developer / How to execute code inside templates?

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

eZ debug

Timing: Jan 18 2025 18:20:21
Script start
Timing: Jan 18 2025 18:20:21
Module start 'content'
Timing: Jan 18 2025 18:20:22
Module end 'content'
Timing: Jan 18 2025 18:20:22
Script end

Main resources:

Total runtime0.8638 sec
Peak memory usage4,096.0000 KB
Database Queries205

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 587.7344180.8281
Module start 'content' 0.00730.6832 768.5625607.8438
Module end 'content' 0.69050.1732 1,376.4063337.0547
Script end 0.8637  1,713.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.4885210.0002
Check MTime0.00160.1813210.0001
Mysql Total
Database connection0.00120.135210.0012
Mysqli_queries0.771589.31312050.0038
Looping result0.00250.28702030.0000
Template Total0.824095.420.4120
Template load0.00200.236320.0010
Template processing0.821995.159620.4110
Template load and register function0.00020.021710.0002
states
state_id_array0.00080.094010.0008
state_identifier_array0.00120.137820.0006
Override
Cache load0.00160.1904270.0001
Sytem overhead
Fetch class attribute can translate value0.00180.212640.0005
Fetch class attribute name0.00180.207680.0002
XML
Image XML parsing0.00150.172840.0004
class_abstraction
Instantiating content class attribute0.00000.002390.0000
General
dbfile0.00790.9089340.0002
String conversion0.00000.000930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs