eZ Community » Forums » General » Question about templates and extensions
expandshrink

Question about templates and extensions

Question about templates and extensions

Monday 08 March 2010 11:07:48 am - 5 replies

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.

Monday 08 March 2010 1:48:37 pm

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,

Monday 08 March 2010 2:24:20 pm

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?

Monday 08 March 2010 3:20:40 pm

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'? big-smile.gif Emoticon.

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.

Wednesday 31 March 2010 11: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

Modified on Wednesday 31 March 2010 11:08:42 pm by Russell Michell

Thursday 01 April 2010 6:18:56 am

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.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from