Gossamer Forum
Quote Reply
plugin create question
I'm going to create a few plugins for myself... I want to create a few simple ones first for test.

My first question is "When you uninstall a plugin, does it automatically delete all of your files, or is there a section where you tell it to delete your files. If so, how does it know what files to delete.

Second question... I understand how to run functions before and after existing sub routines, and I understand how to edit files you create. How do I edit files already in links. If I changed say one line of build.pm, I would also have to write another line in the uninstall sub routine to change it back right?

Just trying to understand how this works,

Any help or comments is appreciated:

- Jonathan
Quote Reply
Re: [jdgamble] plugin create question In reply to
I am certainly no expert, not even a rank amateur, however I think I recall a section in the manual about the creation of plugins. Certainly the previous version manual.

Maybe it is your questions are not addressed very well in there.
Quote Reply
Re: [Gypsypup] plugin create question In reply to
I've searched the manual, even the help section, but It doesn't explain exactly how to edit an already existing linksSQL file that is part of links.

- Jonathan
Quote Reply
Re: [jdgamble] plugin create question In reply to
You would probably want to just install a modified version of the file rather than edit an original file on the fly.

So... in your install file, you'd just move/rename the original file and install your modified file in its place. Then in your uninstall file you would remove your custom file, and rename the original back again.

Hope that makes sense.

r
Quote Reply
Re: [ryel01] plugin create question In reply to
Interesting Enough, I guess I'll just have to mess with it.

Appreciate the response,

- Jonathan
Quote Reply
Re: [jdgamble] plugin create question In reply to
yeah the best idea is just to download a few plugins and open them up and see how they work.

r
Quote Reply
Re: [jdgamble] plugin create question In reply to
Quote:
My first question is "When you uninstall a plugin, does it automatically delete all of your files, or is there a section where you tell it to delete your files. If so, how does it know what files to delete.

To an extent. You have to use $c->uninstall_options() to remove an option, and $c->uninstall_hook() to remove a hook.

The .pm file itself (i.e Thumb_Images.pm), is deleted when you remove the plugin (i.e Plugins > Uninstall).

Quote:
Second question... I understand how to run functions before and after existing sub routines, and I understand how to edit files you create. How do I edit files already in links. If I changed say one line of build.pm, I would also have to write another line in the uninstall sub routine to change it back right?

Kinda. Depending on what you are trying to achive; a hook may be better for you. Basically, it lets you add your own functions, without editing the core codes.

Hope that helps.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] plugin create question In reply to
Ok, so if I decide to use a hook instead of an existing sub routine, how to I make sure every time that sub routine is called through out links it runs my sub routine instead of the existing one?

I think I understand this much, but I'm not sure. So the hook would pretty much do something like this right...

Code:

sub existing_routine {
#------------------------
&start_my_sub_routine;

yada yada yada

}


But how would I tell it not to run existing sub routine at all? Is that what the stop hook is for? I'm sure I could figure this out, but I don't quite grasp the concept of hook right now.

- Jonathan
Quote Reply
Re: [jdgamble] plugin create question In reply to
Here is an example of what I use in Recip_Link;

Code:
$mgr->install_hooks ( 'Recip_Link', [ ['user_add_link', 'POST','Plugins::Recip_Link::do_after_checks', 'FIRST'] ]);


... and then in Recip_Link.pm, you would have something like;

Code:
sub do_after_checks {

my @args = shift;

# do your stuff here...

return @args;

}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!