Callback Issues in plugin. Your expertise Needed.

peregrineperegrine MVP
edited July 2012 in Development
preg_replace_callback($search, "Myfunction", $text);

I can make a callback if my Myfunction resides outside of the class TestPlugin extends Gdn_Plugin {  ...}


          function Myfunction($variable) {    

I can't find a solution.  Anybody know one.    

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

Comments

  • TimTim Operations Vanilla Staff

    preg_replace_callback($search, array($this, 'Myfunction'), $text);

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

    peregrineUnderDog
  • TimTim Operations Vanilla Staff

    More info here: http://php.net/manual/en/language.types.callable.php

    A method of an instantiated object is passed as an array containing an object at index 0 and the method name at index 1.

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

    peregrineUnderDogTrey
  • thx much Tim. I'll give it a try.

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

    UnderDog
  • @Tim - your suggestion worked perfectly.

    Now you can add the autolink plugin to the vanilla forum site itself :).

    Don't know how it would affect performance if there are alot of tags or if if it would be too cluttered. But it would save time adding links to wiki and bonk, etc and provide clickable tags throughout the comments.

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

    UnderDog
Sign In or Register to comment.