php codes in templates

Author Message

justin kazadi

Thursday 08 May 2008 7:56:49 am

Hello all,

I want to know if it is possible to include the php code in the templates files like this:

<?php

echo"bonjour";

?>

The theory is when we know everything and nothing works.
The practice is when everything works and nobody knows why.
If the practice and theory are met, nothing works and we do not know why.

Albert Einstein

Piotrek Karaƛ

Thursday 08 May 2008 8:41:37 am

No, it's not possible and it is not meant to. You can gain access to your custom PHP code via custom template operators, for example.

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Maxime Thomas

Friday 09 May 2008 2:07:52 am

Hi,

The main point of the Template engine is to provide an abstract layer between your language (PHP) and the view (~HTML). It's useful to help separating the view from the controler in an MVC despign pattern.
So if you put PHP in your templates, you are breaking the abstract layer and by this way the MVC pattern.

Cheers.

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

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 20 2025 17:39:58
Script start
Timing: Jan 20 2025 17:39:58
Module start 'layout'
Timing: Jan 20 2025 17:39:58
Module start 'content'
Timing: Jan 20 2025 17:39:59
Module end 'content'
Timing: Jan 20 2025 17:39:59
Script end

Main resources:

Total runtime1.1150 sec
Peak memory usage4,096.0000 KB
Database Queries59

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 587.9063151.2109
Module start 'layout' 0.00580.0025 739.117236.6328
Module start 'content' 0.00831.1059 775.7500607.3594
Module end 'content' 1.11420.0008 1,383.109411.8750
Script end 1.1149  1,394.9844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2820160.0002
Check MTime0.00130.1155160.0001
Mysql Total
Database connection0.00090.082010.0009
Mysqli_queries1.071396.0863590.0182
Looping result0.00050.0451570.0000
Template Total1.086897.520.5434
Template load0.00220.197120.0011
Template processing1.084697.276420.5423
Template load and register function0.00010.008310.0001
states
state_id_array0.00110.096610.0011
state_identifier_array0.00080.076120.0004
Override
Cache load0.00170.1563180.0001
Sytem overhead
Fetch class attribute can translate value0.00060.055330.0002
Fetch class attribute name0.00080.072560.0001
XML
Image XML parsing0.00160.139630.0005
class_abstraction
Instantiating content class attribute0.00000.000760.0000
General
dbfile0.00100.0894290.0000
String conversion0.00000.000740.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
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.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: 13
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs