Question about templates and extensions

Author Message

Carlos Revillo

Monday 08 March 2010 2:07:48 am

Hi there. Sometimes, some extensions 'override' the provided by ez publish in order to add new functionality.

For example, ezxmlexport has its own design/admin/templates/class/view.tpl

This template is just a copy of the default one, and it adds some little code to show if the class is exportable or not.

But it could also happend that other extensions could have its own design/admin/templates/class/view.tpl. For example, http://projects.ez.no/ezclasslists has also this template. The functionality it adds is telling you how many objects of a class exists.

But if you have both enabled, only one functionality will be shown. I mean, ez will ask for:

  1. design/admin/templates/class/view.tpl
  2. extension/ezxmlexport/design/admin/templates/class/view.tpl
  3. extension/ezclasslist/design/admin/templates/class/view.tpl

and only the last will be loaded, so the functionality for ezxmlexport will be lost...

How can the two will be shown?.

Best.

Nicolas Pastorino

Monday 08 March 2010 4:48:37 am

Hi Carlos,

I am afraid the only solution in this case is to create a custom one merging the 2 required features (one from one of the extensions, and the other from the other extension), and make sure it is loaded in place of the 2 other override templates. Making sure it is loaded usually goes through adjusting the ActiveExtensions[] order in site.ini

Let us know how it goes!
Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Gaetano Giunta

Monday 08 March 2010 5:24:20 am

Looks like a nice improvement to the current templating system - and afaict, to the ezc template system too, since we do not support 'template inheritance'.

I guess it might be doable via a new template function, even within the current system: {inherit} instead of {include}. Anybody willing to work on this?

Principal Consultant International Business
Member of the Community Project Board

Carlos Revillo

Monday 08 March 2010 6:20:40 am

I've been talking about this with Nicolas and Bratt at irc channel. My thought is doing something similar to Drupal here. If you prefer, something similar to login handlers or custom edit handlers.

This way, you will have the default template. (let's suppose design/admin/templates/class/view.tpl ) In some part of it you will it that {inherit} or whatever. That function can ask the extensions somehow 'what do you have for me'? :D.

Extensions could add then something like

extension/myextension/hooks/design/admin/templates/class/view.tpl. That will be a piece of code and not the entire template.

Of course some tweaks will be needed for the actual template. Some setting or whatever telling not use the current override system and usign hooks.

Example above is related one template. But when you add an extension you don't know what templates it contains. So maybe you add your ezxmlexport extension. ok. but 2 years leater you decide to try ezclasslist. activate it and ezxmlexport stuff will disappear from your class/view modules.

Best.

Russell Michell

Wednesday 31 March 2010 2:07:16 pm

Carlos,

In the interim, note that the order in which you have your extensions declared in settings/override/site.ini.append.php affects how template overrides are dealt with.

If you know what differs between 2 extensions who use the same template, you'll know what is the best order to declare them in the [ExtensionSettings] block - it being unlikely (possible though) that the exact same code has been modified in the same template for both extensions.

Note also that the order of importance in this array is kinda upside-down. Extensions declared at the top override extensions declared below (In terms of their .ini settings, templates, design-files etc) one would think the ther way around would be more inuitive.

There is a "gotcha" with this in that when you use the admin GUI to install a new extension, and you hit the "Regenerate autoload arrays" button, eZ destroys your lovely, well-crafted extension order in the [ExtensionSettings] block - so ensure you have a copy of your original order. This has bitten me a few times, and is especially important if you use the siteaccess+exension method of multiple siteaccesses in eZ

See the bug-report (now resolved) I submtted on this a while back.

Cheers
Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Carlos Revillo

Wednesday 31 March 2010 9:18:56 pm

Hi Russell.

It's not a question about how you order your extension. i'm not talking about modifying exact the same code but adding some functionalities to a ez publish standard template, like, for example, viewing information about a class.

no matter how you order your extensions. if you don't take, one of two functionalities will be lost...

Best.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.