Gossamer Forum
Quote Reply
How to write a Plugin?

Is there documentation on this anywhere?


- wil
Quote Reply
Re: [Wil] How to write a Plugin? In reply to
I learned from the following sources:

- looking at the sample plugins provided by Jason.
- the Help function in the admin section of GForum is also useful (for information about plugins in general and also for details about GT modules).
- help function of LinksSQL is the most useful thing I have found (unfortunately, I don't own it, but you can have a look at it here on the GT website).

To make it easier for developers to make plugins for GForum, I suggest GT writes some sort of reference document (containing e.g. all the available hooks, similar to the LinksSQL documentation).

Happy plugging!

Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [Wil] How to write a Plugin? In reply to
Here's some things I found useful while writing my first plugin:

  • If you do a "grep -r 'Plugins->dispatch' *" in the admin directory (assuming you have *nix shell access), you'll find where all the places where there are plugin hooks.
  • There is a hook on every do function. So when you go gforum.cgi?do=user_profile, there will be a hook do_user_profile (As seen in GForum.pm: GT::Plugins->dispatch($CFG->{admin_root_path} . '/Plugins/GForum', "do_$do", sub { return _plg_do_func_2(@_) }, $do, @args);)
  • PRE hooks are run before the actual GForum code is run. And you can stop this from happening by calling GT::Plugins->action(STOP);
  • POST hooks are run after the GForum code is run, but after the resulting HTML has been printed out (so that if you print anything in your pre hook, the output will come right at the end).
  • Make sure you return what was passed in (if you changed what was passed in and want it to stick, pass it on in its modified form).
  • Get the your plugin settings by using the function: GForum::Plugins->get_plugin_user_cfg('PluginName'); (You'll also need to Use GForum::Plugins).
  • Need variables to use across your functions? $Plugins::GForum::RestrictSig::Var = 'foo';
  • GT::Dumper/Data::Dumper and warn() are your friend Wink
  • Take a look at the other plugins for examples.

    That's all I can think of right now. I've only written one plugin so there's probably so much more to know, but it's a start.

  • Quote Reply
    Re: How to write a Plugin? In reply to
    Thanks for the information, both. You're right; some standard documentation would be very useful.

    I'll give it a shot and see how it goes.


    - wil