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.

eZ debug

Timing: Jan 18 2025 02:59:59
Script start
Timing: Jan 18 2025 02:59:59
Module start 'layout'
Timing: Jan 18 2025 02:59:59
Module start 'content'
Timing: Jan 18 2025 02:59:59
Module end 'content'
Timing: Jan 18 2025 02:59:59
Script end

Main resources:

Total runtime0.6164 sec
Peak memory usage4,096.0000 KB
Database Queries71

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.0078152.6250
Module start 'layout' 0.00510.0028 740.632839.4453
Module start 'content' 0.00790.6066 780.0781666.8750
Module end 'content' 0.61450.0018 1,446.953116.1563
Script end 0.6163  1,463.1094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.5948160.0002
Check MTime0.00130.2143160.0001
Mysql Total
Database connection0.00070.116210.0007
Mysqli_queries0.549389.1261710.0077
Looping result0.00060.1024690.0000
Template Total0.589295.620.2946
Template load0.00210.334020.0010
Template processing0.587195.243120.2935
Template load and register function0.00040.060010.0004
states
state_id_array0.00090.146610.0009
state_identifier_array0.00060.093120.0003
Override
Cache load0.00180.2945520.0000
Sytem overhead
Fetch class attribute can translate value0.00090.153140.0002
Fetch class attribute name0.00200.319090.0002
XML
Image XML parsing0.00150.247640.0004
class_abstraction
Instantiating content class attribute0.00000.004390.0000
General
dbfile0.00110.1717280.0000
String conversion0.00000.001540.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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 10

Time used to render debug report: 0.0001 secs