Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

add new sub and register it in hooks.cfg

Quote Reply
add new sub and register it in hooks.cfg
Hi
please tell me is there common way to create new sub and automatically (in install) add it in hooks.cfg
I see save to this file only at Profile.pm in DESTROY sub

and after that hook will be added to this sub

When I should add new sub into hooks.cfg not to have problems during install when programm will try to add new hook for new sub.

is it possible at all to do both things in one install?
Quote Reply
Re: [tamwub] add new sub and register it in hooks.cfg In reply to
hooks.cfg is just a list of hooks that appear in Links SQL, it serves no other purpose than to tell you as a plugin author which hooks are available.

In order to register a hook for a plugin, you need to use something like:

$mgr->install_hooks ( 'MyPlugin', [ ['hook_name', 'PRE/POST', 'Plugins::MyPlugin::myfunc', 'FIRST'] ];

If you use the plugin wizard, the wizard will produce those lines for you.

I hope I have understood you correctly and answered your question.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] add new sub and register it in hooks.cfg In reply to
Sorry for my unclear question

I'm asking how to register new function I create (you call it Plugins::MyPlugin::myfunc) and then set hook to it

here is my plugin idea - I add members profile form
now I what when user change his profile some hook will start and do some action (i.e. change user's details in other system - for example vBoard)
Quote Reply
Re: [tamwub] add new sub and register it in hooks.cfg In reply to
If I understand you correctly, you would probably needr:

1) a cgi file, profile.cgi, that is called from the member profile form
2) in this cgi file, you would basically call all the function you want (in your Plugins::MyPlugin module). Since these are new functions, i.e. they don't hook into existing functions, you don't need to register a plugin hook.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] add new sub and register it in hooks.cfg In reply to
Hm
I think you are right
I've already created all need for profile form files...

You open my eyes - there is no need for hooks in my task
thank you