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.
Options

Do the magic events work?

judgejjudgej
edited September 2010 in Vanilla 2.0 - 2.8
The documentation (http://vanillaforums.org/page/Plugins) lists a number of ways a plugin can add its own methods before, after or to replace methods in the core controllers of Vanilla. However, I can only get the custom events to work - that is those events that are triggered by a call to FireEvent().

Do the other magic events work in Vanilla 2.0.6? Namely, can I override core methods from my plugin?

For example I wish to replace UserController->AutoComplete() with an extended version of my own in a plugin (to search on additional user fields). Is that possible? The documentation hints that all I need to do is create the public method UserController_AutoComplete_Override($Sender) in my plugin and it works by magic. Except it does not seem to. Or would I be better off creating completely separate auto-complete functionality to do the stuff I want it to do (namely to hide usernames and show display names)?

Comments

  • Options
    SS ✭✭
    @judgej
    You should rename AutoComplete -> xAutoComplete then UserController_AutoComplete_Override($Sender) in plugin will work (override).
  • Options
    It's the core method I need to rename, and keep track up during any upgrades?
  • Options
    TimTim Operations Vanilla Staff
    We can add an event in the method for you. Where would be best? At the beginning? End? Both?

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Options
    I'm not sure where the best place for an event would be - I guess (like I did for Vanilla 1) I would just add my own events then raise them as feature requests when I know they are in the right place.

    What I am trying to do is to largely hide the usernames from the front end and show "display names" or "real names" instead. This is so far achieved through some existing events and partly through theme overrides. The part that invites people into private conversations is what I am looking at now. I would like the Ajax calls to auto-complete to be able to list the real names and to allow search on the real names, so some extensions to the user model would be needed to be able to inject the additional table joins and return values.


    Alternatively, I could just change the URL used to do the AJAX searches to my own custom lookup and not try to override anything in the core controllers.

    The issue with the usernames is that it is not only the names that people seem but is also the unique identifier for users. This is in complete contrast to the external CMS that Vanilla is integrated in, in which real names can be changed, and are not unique.
Sign In or Register to comment.