1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How To Use Template Hooks

Discussion in 'Official Development Tutorials and Resources' started by Kier, Mar 6, 2011.

  1. Kier

    Kier XenForo Developer Staff Member

    Following the introduction of the mega footer here on XenForo.com, which I said was included using template hooks and requires no direct template edits, this video tutorial talks about template hooks, what they are and why you would want to use them.

    It then goes on with a few examples to get you started.

    Or view on Vimeo
    shri, octabrain, kalco and 42 others like this.
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Great timing as I'm just about to start on my footer links add-on.
  3. EQnoble

    EQnoble Well-Known Member

    Fuhrmann and Kier like this.
  4. DoctorWatsOn

    DoctorWatsOn Well-Known Member

    Excellent! :cool:
  5. Dan

    Dan Well-Known Member

    This is great Stuff!! Thanks Kier!
  6. Walter

    Walter Well-Known Member

    Thank you very much. Straightforward and easy.
  7. James

    James Well-Known Member

    Very nice insight into the template hook system - thanks!
  8. Michael Dance

    Michael Dance Active Member

    Wow your a fast coder ;) i think this is helpful also for beginners in coding addons for XenForo. Thanks mate :)
  9. Kier

    Kier XenForo Developer Staff Member

    You should see Mike [​IMG]
    Jeremy and EQnoble like this.
  10. EQnoble

    EQnoble Well-Known Member

    We should :)
    D.O.A., =MGN=RedEagle and Dan like this.
  11. Dan

    Dan Well-Known Member

    I agree. At the risk of sounding creepy. I love watching these just to see how fluid the thought process is when explaining what each function is and why he is typing what he is typing. It's like watching an artist painting.
    RobinHood, SchmitzIT, Peggy and 7 others like this.
  12. James

    James Well-Known Member

    @goblues... definitely one I haven't heard before... [​IMG]
    Michael Dance likes this.
  13. Dan

    Dan Well-Known Member

    Leave it to me [​IMG]
    James likes this.
  14. EQnoble

    EQnoble Well-Known Member

    and on that note....

    Just finished with another round of watching the video...this one is particularly great at explaining what goes where and WHY and I am confident that in 10 minutes when my coffee is gone..I will have no problem first time around implementing this.

    Which brings me to an awesome revelation...
    Dan likes this.
  15. James

    James Well-Known Member

    Repeatedly clicks What's New in about 9 minutes 30 seconds...
    EQnoble likes this.
  16. George

    George Active Member

  17. Dean

    Dean Well-Known Member

    Have him do a video [​IMG]
    Mikey, EQnoble, Sadik B and 4 others like this.
  18. Rigel Kentaurus

    Rigel Kentaurus Well-Known Member

    While I love the concept of template hooks, there are some concerns that I would really like to have addressed:

    1. I would like a way to "expose" which templates are being modified by template hooks, this might sound simple now, but after I start installing dozens of plugins, finding out which addon modifies what could turn into a nightmare, really fast, really soon. I could always go and check what listeners are being applied, then check that listener class individually ... This sounds like it could lead to countless hours of debugging

    2. Is it possible to modify the template at compilation time, instead of at generation time? Right now it seems that it is modified at runtime, appending or modifying contents, but I would also like to be able to, say, modify the actual template definition. This is a little different in the sense that the hook would be applied once when the add-on is compiled and everytime the templates are recompiled. Could we maybe have both?

    3. I feel a little uneasy by the feeling that if there are 100 hooks in templates, and I have a listener, that same listener is called for the 100 hooks.. is that the case? so, for example, if I want to modify a fragment of thread_view, I add a template hook and suddenly that hook is called for every single template on the site everywhere? home - called, members - called, etc - called .. Maybe I am over-obsesive and the "switch ($hookName)" is so unexpensive this is not a problem. Please give me reassurance.
  19. Kier

    Kier XenForo Developer Staff Member

    1. This is not a perfect system. We'd like to do something more extensive in the future, but for now this at least does the job of allowing edits without editing (if you know what I mean)
    2. No, this has to be done at runtime with the current approach
    3. switch() statements are very, very cheap.
    EQnoble likes this.
  20. SneakyDave

    SneakyDave Well-Known Member

    This is probably a stupid question, but I'm trying to follow along with the vimeo presentation, and I don't seem to have a paragraph that displays the "Callback signature" on the "Code Event Listener Editor" page, like it does in Kier's vimeo production.Why would that be?

    Not a big deal, it's easy enough to copy from the list of Arguments on the list, but just curious.

Share This Page