How to utilize the pre_template hook

Author Message

Erik Weinmaster

Monday 08 February 2010 8:34:33 am

I can see the 'pre_template' hook on line 494 of kernel/content/attribute_edit.php, however, I'm not sure how to set-up code to hit this hook. I need to set some custom template variables and this looks to be about this place to do that.

-thanks

Bertrand Dunogier

Monday 08 February 2010 2:09:24 pm

Unfortunately, these hooks are usable out of the box.

attribute_edit.php is used by kernel/content/edit.php. edit.php does use the hook system, to add content actions. But the only way to re-use these hooks by yourself would be to write a minimalistic module+view, that loads the content module, adds the custom hook, and forwards the request to edit.

What do you need to do exactly ?

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Erik Weinmaster

Tuesday 09 February 2010 7:22:44 am

Right now I have a template file that overloads the edit_attribute.tpl file so that I can show the edit page specifically how I want it. However, what I need is to access an external database and set a template variable to decide which attributes will be shown (obviously all attributes are available on the backend, but depending on where you access this node you'll see different attributes). Unfortunately, I'm having trouble setting up code to hit one of the hooks in the edit process.

-thanks

Bertrand Dunogier

Tuesday 09 February 2010 8:59:40 am

Honestly, I would play the lazy card, and write a custom fetch function for this, that I'd call at the top of my custom template

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Erik Weinmaster

Tuesday 09 February 2010 10:55:02 am

Ok, I see what you're saying, but I've never accessed an external db from the tpl files. I'm guessing is roughly the same as a typical template fetch operation?

Bertrand Dunogier

Wednesday 10 February 2010 2:36:56 am

Not roughly, exactly :-)

If you need to access a 3rd party DB, you can easily use eZDB if you want. I can't add much now, but if you need more details, you know where to ask.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

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 05:16:35
Script start
Timing: Jan 18 2025 05:16:35
Module start 'layout'
Timing: Jan 18 2025 05:16:35
Module start 'content'
Timing: Jan 18 2025 05:16:36
Module end 'content'
Timing: Jan 18 2025 05:16:36
Script end

Main resources:

Total runtime0.8991 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 589.0547152.6250
Module start 'layout' 0.00690.0036 741.679739.4453
Module start 'content' 0.01050.8864 781.1250564.6953
Module end 'content' 0.89690.0021 1,345.820316.4688
Script end 0.8990  1,362.2891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.4497160.0003
Check MTime0.00190.2153160.0001
Mysql Total
Database connection0.00080.093910.0008
Mysqli_queries0.827692.0494660.0125
Looping result0.00070.0832640.0000
Template Total0.865996.320.4330
Template load0.00250.274720.0012
Template processing0.863496.037020.4317
Template load and register function0.00020.024810.0002
states
state_id_array0.00030.032710.0003
state_identifier_array0.00100.109120.0005
Override
Cache load0.00210.2388220.0001
Sytem overhead
Fetch class attribute can translate value0.00060.064520.0003
Fetch class attribute name0.00230.251870.0003
XML
Image XML parsing0.00080.091120.0004
class_abstraction
Instantiating content class attribute0.00000.002590.0000
General
dbfile0.00100.1089160.0001
String conversion0.00000.001040.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
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs