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

Writing an extension to send a PM when "like" is clicked

Discussion in 'XenForo Pre-Sales Questions' started by ForestForTrees, Feb 14, 2012.

  1. ForestForTrees

    ForestForTrees Well-Known Member

    In the process of researching our forum purchase, I came across the above quote on another admin forum and instantly realized that this is exactly what we need.

    Our community is a support community for people with intense long term chronic pain. It's pretty intense, and experienced members take time out of their busy schedules to support newer members. A system that transforms a "like" into an opportunity to send a message to the author of the liked post would be a big deal of our forums. It would make posting much more gratifying for the experienced members, increase retention of those same members, and ensure that people got better support.

    How would one go about modifying XenForo to have something where if one clicked on "like," a field popped up that prompted you to send a PM to the person to thank them?

    I ask this because, whatever forum software we go with, I plan to get pretty deep into the innards, writing extensions. I've already gotten pretty deep into our MediaWiki installation, writing extensions in PHP, and expect to do the same, only more so, in the forum. (The natural experience is, "do I have experience with Javascript and jQuery. I don't, but I've written a bunch in C and other languages, so while I know a lot is involved, I'm not going to let that stop me. I figure that when there's a will there is a way. After all, people probably said that it was impossible for a small startup to take on the vBs and IPBs of the world... ;) )

    Given the above, before we make our final purchase decision, I'd like to get a sense of what it's like to write extensions for the various platforms we are considering. The only way to really get a feel for a software framework is to dig in and start designing software in it, so in addition to asking this question because I want to make that particular extension, I also want to seriously investigate how I'd write this thing, so I can get a feel for the platform. Hence, please go into as much detail as you are willing about which hooks I'd want to listen for and which tutorials or open source projects I'd want to look at.

    I'm a bit apprehensive particularly with XenForo because of the JavaScript and jQuery, so, since I've brought all of this up, I'd certainly love to hear what people have to say about how it affects writing extensions for XF.

    Thanks in advance for reading this far and any feedback you can give.
     
  2. ForestForTrees

    ForestForTrees Well-Known Member

    An example of what I'm describing can be found at "TheAdminZone:"
    http://www.theadminzone.com/forums/showthread.php?t=90993

    Next to the post number for every post is a set of scales. You click on these scales to give Karma and when you do, a little popup appears:
    Karma
    Add to Karma: Nev_Dull
    What do you think of Nev_Dull's post?
    Good! Karma++
    Your comments on this post:


    There are two things that I really love about this. First, it feels like a complement to the person rather than just to the post. That feels more meaningful and, frankly, more motivational (key).

    The second is that in a very innocuous and low pressure way it prompts you to send a little note.

    Any thoughts on how to write an addon to do this in XF?
     
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You will need to extend this function:

    XenForo_ControllerPublic_Post::actionLike

    That is the controller that handles the request when some one clicks the "Like" link in a post. It can be extended to handle additional input such as a "thank you" note. If you want to send the note as a PM then you would invoke XenForo_DataWriter_ConversationMaster inside of your extended function. You can see an example of using this datawriter if you look in XenForo_ControllerPublic_Conversation.

    Here is a tutorial for extending controllers:

    http://xenforo.com/community/threads/how-to-add-more-actions-to-an-existing-controller.11202/

    If you extend an existing controller then you can use the same function name as the original controller to extend that action.
     

Share This Page