Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Hooking in with plugins

Hello!
I was wondering, is there a list of possible hooks for vanilla? For example if I wanted to hook into the left menu under say.. the start new discussion button, what and how would I hook into it?

Cheers

«1

Comments

  • 422422 Developer MVP

    check out the wiki ( its in @hbf ) signature

    There was an error rendering this rich post.

  • I have checked the wiki, couldn't seem to find it anywhere though

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • It's good but it breaks the theme meaning it's hard to actually find the hook you need :/

  • peregrineperegrine MVP
    edited March 2013

    @Judge said:
    It's good but it breaks the theme meaning it's hard to actually find the hook you need :/

    if you don't like that roll your own

    grep -ri "FireEvent" *

    but as far as docs that explain hooks and what they reference - not that I've seen.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • businessdadbusinessdad Stealth contributor MVP
    edited March 2013

    In the past I simply added a var_dump() inside the Gdn_Pluggable::FireEvent() method, showing the class and the event name. It still "broke" the theme, somehow, but it was useful to figure out when each event was fired. It allowed me to understand which event to intercept to "inject" stuff in the theme.

    I think this is similar to what Eventi Plugin does, other than adding more details about the event.

  • Ah ok thanks guys.

  • hgtonighthgtonight ∞ · New Moderator
    edited March 2013

    For a full list, check out the wiki.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight said:
    For a full list, check out the wiki.

    nice update @hgtonight

    is it for vanilla 2.0.18.4 or vanilla 2.1?

    &$Sender probably better as $Sender throughout.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hgtonighthgtonight ∞ · New Moderator

    @peregrine I am only adding/updating the wiki for the current vanilla 2.0.x.

    I look forward to the 2.1 release though :D

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • x00x00 MVP
    edited March 2013

    you don't need & regardless, php object are passed by reference. If it was some think like a array that si a different matter. & does nothing and will break in future versions.

    grep is your friend.

  • peregrineperegrine MVP
    edited March 2013

    @x00 said:
    you don't need & regardless, php object are passed by reference. If it was some think like a array that si a different matter. & does nothing and will break in future versions.
    @x00 said:
    you don't need & regardless, php object are passed by reference. If it was some think like a array that si a different matter. & does nothing and will break in future versions.

    One question:

    1) Are hooks for 2.1 or 2.0.18 - answered 2.0.18. So Title is "Eventlist for vanilla 2.0.18.4" :)

    One Statement unrelated to the above question.

    2) exactly x00 - probably best to remove & as it is not needed for Sender. period. no matter what the version of vanilla as long as php 5 (or whenever they changed the references for objects), and the plugin will often break in version 2.1. Just a thought for future docs.

    edited: Thanks for the quick edit to fix #2 @hgtonight

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks for the list of hooks, hgtonight. It was useful.

  • LincLinc Detroit Admin
    edited July 2013

    I know it's a much steeper learning curve, but if you can get a mental model of how Vanilla works, it kinda makes a list of events seem not very useful, because you can just drill right to the location you'd want the hook anyway and find its name.

    Example: "I wanna hook into the Profile edit page"

    I know profiles are part of the Dashboard app, and it says "profile/edit" in the URL, so that's the "profile" controller, so I'm looking at /applications/dashboard/controllers/class.profilecontroller.php for the Edit method to see what events are in the logic, and at /applications/dashboard/views/profile/[probably edit.php?] for what events are in the template.

    Example: "I need to change how a form element works"

    I know forms are a core part of Vanilla and used in every app, and in fact has its own class, so I'm headed to /library/core/class.form.php and looking for a method named for the form element I want to mess with.

    Addendum: I use full code search A LOT. "Hmmm... I wanna change a category ID after a discussion is saved... AfterDiscussionSave?" [searches] Ding.

  • hgtonighthgtonight ∞ · New Moderator
    edited July 2013

    @Deonte No problem! I don't think I have seen you before, so welcome to the community!

    @Lincoln said:
    I know it's a much steeper learning curve...

    Good post on the process. It is very close to what I (and presumably others) use daily. The issue is that it requires a) a time commitment to learn Vanilla's flavor or code organization (try it; it's delicious!) and b) reading/searching code. Plenty of people are uncomfortable reading code. Especially frameworks that do a lot of "magic stuff."

    So we make lists. Any new information? Not really. More accessible? Definitely! They help new community members earn their development chops. Very quickly they will hopefully adopt a process like you outlined. Until then, I am happy I could help!

    P.S. If it makes you feel better, that wiki page markup was generated by running some regexes against the source files :)

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • LincLinc Detroit Admin
    edited July 2013

    I wasn't complaining about lists, I was just pointing at the next step on the path (for those who want the steep way up the mountain). :)

  • businessdadbusinessdad Stealth contributor MVP

    @hgtonight said:
    The issue is that it requires a) a time commitment to learn Vanilla's flavor or code organization (try it; it's delicious!) and b) reading/searching code. Plenty of people are uncomfortable reading code. Especially frameworks that do a lot of "magic stuff."

    Vanilla is one of the few frameworks where I found "convention over declaration" done right. I work with other frameworks and some pride themselves to follow "declaration over convention", i.e. they require an XML file for every single change you make, another XML file to describe the first one, another to group the other two and, if one little thing is out of place, everything just gets ignored. No errors, no logs. I wonder how can anyone be pride of such an abortion, I would be ashamed...

  • peregrineperegrine MVP
    edited July 2013

    Plenty of people are uncomfortable reading code.

    should they be hooking events with plugins :)

    rhetorical question :) no need to answer.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Yes no hooking for them....

    learn Vanilla's flavor or code organization (try it; it's delicious!)

    Yes it is, many people come in here and say they don't know php etc but this code actually teaches you php without noticing. It looks foreign at first but once you figure out the logic it starts to make sense. You wonder , it can't be this obvious ? But it is :) yum*

    I use full code search and find too! I thought it might be overkill but there is no other way to go through it all semi fast.

    People think it is more complex and try crazy things when one $Configuration takes care of it (done that, thanks @Lincoln )....

  • aeryaery Gtricks Forum in 2.2 :) ✭✭✭
    edited July 2013

    Often I use File Locator Pro for text search in Vanilla Directory. Its grep for windows with GUI.

    A must for any Vanilla enthusiast. Just enter your term (Howdy Stranger, fireevent etc)

    http://www.mythicsoft.com/filelocatorlite

    Also, not to forget NotePad++ for editing files.

    There was an error rendering this rich post.

Sign In or Register to comment.