Gossamer Forum
Quote Reply
Plugin of a plugin?
I'm thinking to develop a plugin for my plugin.
Sounds strange? Smile
Yeah, I'm sure it sounds strange. Wink
I think it would be possible to do the same trick, what Alex used to treat plugins.

Opinions?
Alex, Staff, developers, let me know what do you think about this idea?

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Plugin of a plugin? In reply to
Im not sure of any reason why you'd need to do it.

Could you explain?

Last edited by:

Paul: Apr 25, 2002, 8:58 AM
Quote Reply
Re: [Paul] Plugin of a plugin? In reply to
If some plugins are using the same replaced codes, e.g. site_html_link, you would not be able to install those plugins together.

But if one plugin has hooks to insert, include the other plugin, then using these plugins together would be possible. That's my first reason.

Another reason is, that I don't want to release my second plugin merged with the first, because the first one is planned to be released as a fairly cheap plugin, and the second one, is planned to be released as a more expensive plugin, because it will be able to make money with it. Therefore I don't want to mix these plugins, but they commonly use (replace) some subroutines, so I have to use them together somehow. The solution could be the plugin of a plugin solution.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Plugin of a plugin? In reply to
>>
If some plugins are using the same replaced codes, e.g. site_html_link, you would not be able to install those plugins together.
<<

Are you sure?....I always thought you could install more than one plugin using the same hook although I've never tried.
Quote Reply
Re: [Paul] Plugin of a plugin? In reply to
Quote:
Are you sure?....I always thought you could install more than one plugin using the same hook although I've never tried.
Yes, you could install, but they will only work seamlessly, if you do not replace original code in them.

Remember this info in plugins:
Quote:
# You should call GT::Plugins->action ( STOP ) if you don't
# want the regular code to run, otherwise the code will continue as
# normal.
But if you replace original code, using GT::Plugins->action ( STOP ), and you install 2 plugins replacing same original code, then only one replacement will be active, or both will be executed (does not really matter, both are wrong for us).

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Plugin of a plugin? In reply to
Hmm yeah I see what you mean.
Quote Reply
Re: [webmaster33] Plugin of a plugin? In reply to
Hi,

Yes, this is defiantely possible. In your plugin, just call your methods:

my $results = GT::Plugins->dispatch($CFG->{admin_root_path} . '/Plugins', 'my_hook_name', \&some_function);

Then your plugin can hook into 'my_hook_name'.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Plugin of a plugin? In reply to
Alex, you are great! Thanks your quick info!
I'm glad it is possible to have plugin hook in a plugin.

Alex, Do I need this trick to define the hooked sub? E.g.:
Code:
$SUBS{my_hook_name} = <<'END_OF_SUB';
...
END_OF_SUB

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Plugin of a plugin? In reply to
Hi,

No, that trick is to autoload code. Because each time you run a .cgi perl must compile all your code, we've gone to autoloading subroutines to improve startup time. Instead of having to parse all your functions, we simple store the function as a single string. When you actually call the function for the first time, it gets eval'd and turned into real code. This is quite separate from the plugins.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Plugin of a plugin? In reply to
Ok. I thought this is the way how hooking was solved. Blush
Could you tell me in a few words how the plugins are working?

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Plugin of a plugin? In reply to
Hi,

It's actually quite simple. Throughout the code you'll see:

GT::Plugins->dispatch($CFG->{admin_root_path} . '/Plugins', 'hook_name', \&code_ref);

Wherever you see that, it defines a plugin called hook_name, for the function code_ref. So, for example in search.cgi:

GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'handle_search', \&Links::User::Search::handle);

This means if you hook into 'handle_search', then you are overriding, or running before/after the function Links::User::Search::handle. It's up to the programmer to use GT::Plugins->dispatch in appropriate places, to define what code can be plugged.

Let me know if this doesn't make sense,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Plugin of a plugin? In reply to
Alex,
Thank you very much! This will help me in my plugin developments.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Plugin of a plugin? In reply to
It's a question I've wanted to ask Alex about too :) Very helpful!


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Plugin of a plugin? In reply to
Yep, Alex is a great mind! And he gives very helpful & detailed answers!
He knows Links scripts down to the "code bones". Wink

Of course. Because he is father of the scripts. Wink

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...