possible to apply filter on eZP templates?

Author Message

Marko Žmak

Sunday 05 June 2011 8:51:34 am

Is it possible to apply a filter (custom function) on the content of eZP templates (.tpl files) before they are parsed or compiled to PHP?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Jérôme Vieilledent

Sunday 05 June 2011 1:53:40 pm

Hi Marko

What do you mean ? A template operator ?

Gaetano Giunta

Sunday 05 June 2011 2:37:51 pm

I was just going to post a feature request that would solve the need at hand: allow the developer to register different 'resource handlers' for the eztemplate class.

This way it would be possible to:

- use the include tpl operator using other namespaces than 'file:' and 'design:' (note: this can also be used when giving a custom pagelayout name in $Results within a module), to allow eg. usage of different template engines

- customize the handler of the standard templates to add some nifty tricks

Principal Consultant International Business
Member of the Community Project Board

Marko Žmak

Monday 06 June 2011 5:29:28 am

@jerome: This is what I mean...

The normal process of eZP template loading and parsing goes like this:

  1. template content is loaded from the template (.tpl) file into a PHP variable (let's say $text)
  2. the content of $text variable is processed and compiled to PHP

What I would like to do is to insert a custom PHP function between step 1. and 2. which would operate on the $text variable and change it's content somehow.

Is this possible?

@gaetano...

Would the feature request you are suggesting solve what I'm looking for?

It looks like your suggestion would work only on templates invoked via template include, and not for templates loaded from override, *_view_gui, OE tags, embed objects...

Am I right?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

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 02:10:12
Script start
Timing: Jan 18 2025 02:10:12
Module start 'layout'
Timing: Jan 18 2025 02:10:12
Module start 'content'
Timing: Jan 18 2025 02:10:12
Module end 'content'
Timing: Jan 18 2025 02:10:12
Script end

Main resources:

Total runtime0.6383 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 589.1641152.6406
Module start 'layout' 0.00590.0028 741.804739.4844
Module start 'content' 0.00870.6283 781.2891609.0625
Module end 'content' 0.63700.0013 1,390.351612.1250
Script end 0.6383  1,402.4766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.5104160.0002
Check MTime0.00140.2188160.0001
Mysql Total
Database connection0.00070.113310.0007
Mysqli_queries0.580190.8905620.0094
Looping result0.00060.0996600.0000
Template Total0.610395.620.3052
Template load0.00210.330920.0011
Template processing0.608295.281120.3041
Template load and register function0.00010.016910.0001
states
state_id_array0.00080.123710.0008
state_identifier_array0.00110.179320.0006
Override
Cache load0.00170.2729300.0001
Sytem overhead
Fetch class attribute can translate value0.00060.092430.0002
Fetch class attribute name0.00130.206770.0002
XML
Image XML parsing0.00150.231730.0005
class_abstraction
Instantiating content class attribute0.00000.002180.0000
General
dbfile0.00120.1879310.0000
String conversion0.00000.001740.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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/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
2content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ol.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ol.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs