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.

Order of plugin execution?

edited July 2012 in Vanilla 2.0 - 2.8

So I wanted to add information to the bottom of all the user's posts, similar to the signatures plugin which we are already using.

I did this using
public function DiscussionController_AfterCommentBody_Handler(&$Sender)

The problem I have is, how do I put my content below the signature content which is using the same handler?

Comments

  • just a wild guess - move the plugin name below the signatures in config.php or possibly rename your plugin with a letter starting with T.

    or if all else fails add your mod to the signatures plugin.

    It would be interesting as to what you find out.

    maybe you could figure out plugin loading order somewhere in the core.

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

  • I just checked the config.php and it is already below signatures. I am guessing that it is done in alphabetical order.

  • peregrineperegrine MVP
    edited July 2012

    It would be cool how to find this out by someone in the know, so there doesn't have to be a kluge.

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

  • I just took my bit of code and added it to the signatures plugin... I just have to remember not to updated it. :)

  • LincLinc Detroit Admin

    No, there's not a way to specify the order in which 2 plugins execute the same hook. It's a specificity war we don't want in core.

  • LincLinc Detroit Admin
    edited July 2012

    @Waterskiaddict Even better would be to just add a hook to the Signature plugin, allowing you to grab the new event using your theme's hooks file. Then when you update the Sig plugin, all you have to do is re-add a hook rather than pasting a block of functionality and hoping you don't accidentally overwrite your only copy.

  • edited July 2012

    Lincoln said:
    @Waterskiaddict Even better would be to just add a hook to the Signature plugin, allowing you to grab the new event using your theme's hooks file. Then when you update the Sig plugin, all you have to do is re-add a hook rather than pasting a block of functionality and hoping you don't accidentally overwrite your only copy.

    thanks a lot. also were disterbing the problem with signature

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    I was actually looking to do something like this myself - a plugin used the same hook as some meta information I was adding. I ended up using jQuery to move the meta information after a specific element in the core markup. Turned out to work quite well:

    $('.the-parent-element').each(function() {
        var $your-element = $(this).find('.your-element');
        var $element-content = $your-element.outerHTML();
        var $anchor-element = $(this).find('.anchor-element');
        $your-element.remove();
        $anchor-element.after($element-content);
    });
    

    Here's the outerHTML function used:

    jQuery.fn.outerHTML = function(s) {
        return s
            ? this.before(s).remove()
            : jQuery("<p>").append(this.eq(0).clone()).html();
    };
    

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

Sign In or Register to comment.