Upgrading deprecated language in templates

Author Message

Geoff Bentley

Thursday 07 August 2008 3:06:01 pm

I'm in in the process of cleansing some ezp3.9.x sites which have deprecated code strewn throughout, so I thought I'd throw some examples up for anyone who is starting to do the same in order to upgrade to ezp4.x. The main deprecated functions are:

 {section}
 {let}
 {default}

<i>Section</i> is simple to replace, using <i>if</i> and <i>foreach</i>, e.g:

{section show=ne($classification|trim,"")} class="{$classification|wash}"{/section}

becomes

{if ne($classification|trim,"")} class="{$classification|wash}"{/if}
{section loop = ezini( 'StylesheetSettings', 'EditorCSSFileList', 'design.ini' )}
   EditorCSSFileList[{$index}] = {$:item|ezdesign};
{/section}

becomes

{foreach ezini( 'StylesheetSettings', 'EditorCSSFileList', 'design.ini' ) as $index => $item }
   EditorCSSFileList[{$index}] = {$item|ezdesign};
{/foreach}

<i>Let</i> can be replaced with <i>def</i> and <i>undef</i>:

{let attribute=$node.object.data_map.downloadable_file}
blah blah blah
{/let}

becomes

{def $attribute=$node.object.data_map.downloadable_file}
blah blah blah
{undef $attribute}

<i>Default</i> can be replaced with a condition and a def statement:

{default a=5}

becomes

{if is_unset( $a )}
  {def $a=5}
{/if}

For <i>default</i> code with namespaces, use <i>def</i> and <i>set</i> as mentioned in the comments at http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_functions/variables/set

Hope this is useful.

Geoff Bentley

Thursday 07 August 2008 3:24:02 pm

.

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 19 2025 00:23:55
Script start
Timing: Jan 19 2025 00:23:55
Module start 'layout'
Timing: Jan 19 2025 00:23:55
Module start 'content'
Timing: Jan 19 2025 00:23:56
Module end 'content'
Timing: Jan 19 2025 00:23:56
Script end

Main resources:

Total runtime0.7244 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0043 588.0469152.6406
Module start 'layout' 0.00430.0029 740.687539.4766
Module start 'content' 0.00720.7155 780.1641463.8750
Module end 'content' 0.72270.0017 1,244.03918.1250
Script end 0.7244  1,252.1641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4293160.0002
Check MTime0.00130.1784160.0001
Mysql Total
Database connection0.00080.107810.0008
Mysqli_queries0.676193.3290520.0130
Looping result0.00060.0892500.0000
Template Total0.688395.020.3441
Template load0.00210.296520.0011
Template processing0.686194.707820.3430
Template load and register function0.00010.016910.0001
states
state_id_array0.00200.280610.0020
state_identifier_array0.00150.201520.0007
Override
Cache load0.00180.2495180.0001
Sytem overhead
Fetch class attribute can translate value0.00140.191610.0014
Fetch class attribute name0.00160.220630.0005
XML
Image XML parsing0.00060.078810.0006
class_abstraction
Instantiating content class attribute0.00000.001540.0000
General
dbfile0.00160.2221160.0001
String conversion0.00000.000940.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/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/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.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