Forums / Developer / possible to apply filter on eZP templates?

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

eZ debug

Timing: Jan 17 2025 23:43:49
Script start
Timing: Jan 17 2025 23:43:49
Module start 'content'
Timing: Jan 17 2025 23:43:50
Module end 'content'
Timing: Jan 17 2025 23:43:50
Script end

Main resources:

Total runtime1.3330 sec
Peak memory usage4,096.0000 KB
Database Queries199

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0094 588.9766180.8203
Module start 'content' 0.00941.1677 769.7969614.1563
Module end 'content' 1.17710.1558 1,383.9531337.3672
Script end 1.3329  1,721.3203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.2973210.0002
Check MTime0.00150.1091210.0001
Mysql Total
Database connection0.00150.116310.0015
Mysqli_queries1.263894.80901990.0064
Looping result0.00170.13001970.0000
Template Total1.306398.020.6531
Template load0.00210.154120.0010
Template processing1.304297.845220.6521
Template load and register function0.00010.007210.0001
states
state_id_array0.00060.045010.0006
state_identifier_array0.00070.055720.0004
Override
Cache load0.00170.1284300.0001
Sytem overhead
Fetch class attribute can translate value0.00110.085740.0003
Fetch class attribute name0.00110.086170.0002
XML
Image XML parsing0.00180.134140.0004
class_abstraction
Instantiating content class attribute0.00000.001080.0000
General
dbfile0.00250.1849420.0001
String conversion0.00000.000730.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs