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