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