Forums / Developer / How to utilize the pre_template hook

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

eZ debug

Timing: Jan 18 2025 02:46:01
Script start
Timing: Jan 18 2025 02:46:01
Module start 'content'
Timing: Jan 18 2025 02:46:01
Module end 'content'
Timing: Jan 18 2025 02:46:01
Script end

Main resources:

Total runtime0.1769 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 587.7344180.8281
Module start 'content' 0.00590.0089 768.562597.7891
Module end 'content' 0.01490.1619 866.3516525.9219
Script end 0.1768  1,392.2734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00362.0256200.0002
Check MTime0.00140.7952200.0001
Mysql Total
Database connection0.00080.458610.0008
Mysqli_queries0.123769.95271410.0009
Looping result0.00150.86341390.0000
Template Total0.161691.410.1616
Template load0.00110.608410.0011
Template processing0.160590.759510.1605
Override
Cache load0.00070.368210.0007
Sytem overhead
Fetch class attribute can translate value0.00110.605510.0011
XML
Image XML parsing0.00020.127110.0002
General
dbfile0.00271.5470200.0001
String conversion0.00000.003430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs