Gossamer Forum
Quote Reply
Writing Plug In help
Hi:

I FINAALY broke down and decided to write my first plugin! This one will add a "Lowest Rated" to the ratings page, and allow you to specify the number of Links returned for Top Rated, Top Voted and Lowest Rated... as well as the minimum number of votes needed to be on the list.

My initial plug in worked great... but as I try to add a config page so that users can specify these numbers, I am getting confused.... (this would be from the GT generated "Edit" page)

The "Name" field is the name you want displayed for editing, NOT the variable name... correct? If it is just a TEXT field, how do I specify what variable name I want associated with the input? Here is the code now:

$mgr->install_options ( 'Ratings', [ ['Top Rated Number', '25', 'Enter the number of "Top Rated" you wish returned.', 'TEXT', [], [], '' ] ] );
$mgr->install_options ( 'Ratings', [ ['Top Rated Minimum', '5', 'Enter the minimum number of votes needed for inclusion in the Top Ratings.', 'TEXT', [], [], '' ] ] );
$mgr->install_options ( 'Ratings', [ ['Top Voted Number', '20', 'Enter the number of "Top Votes" you wish returned. ', 'TEXT', [], [], '' ] ] );
$mgr->install_options ( 'Ratings', [ ['Top Voted Minimum', '5', 'Enter the minimum number of votes needed for inclusion in the Top Votes.', 'TEXT', [], [], '' ] ] );
$mgr->install_options ( 'Ratings', [ ['Bottom Rated Number', '10', 'Enter the number of Bottom Rated you wish returned.', 'TEXT', [], [], '' ] ] );
$mgr->install_options ( 'Ratings', [ ['Bottom Rated Minimum', '5', 'Enter the minimum number of votes needed for inclusion in the Bottom Votes. ', 'TEXT', [], [], '' ] ] );


For example, I want:

$mgr->install_options ( 'Ratings', [ ['Top Rated Number', '25', 'Enter the number of "Top Rated" you wish returned.', 'TEXT', [], [], '' ] ] );


to return $tr_num


And secondly,

Do I have to do:

my $tr_num = $IN->param('tr_num');

in the plugin itself, or can I just use $tr_num?

Thanks!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Writing Plug In help In reply to
The field name is the same as the variable name, so to get the value of "Top Rated Number" you'd use:

my $opts = Links::Plugins->get_plugin_user_cfg('YOUR_PLUGIN_NAME');
my $ratings = $opts->{'Top Rated Number'};

Last edited by:

Paul: Apr 14, 2003, 12:11 PM
Quote Reply
Re: [Paul] Writing Plug In help In reply to
Paul:

Thanks!

BTW, what is your sig????
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Writing Plug In help In reply to
It's perl code that prints my initials "PW" =)

Last edited by:

Paul: Apr 14, 2003, 12:28 PM
Quote Reply
Re: [Paul] Writing Plug In help In reply to
Thanks PW! Funny.

I figured it was code, but not something I could solve looking at it!

OK, I added this to the top of the main part of the plug in:

my $opts = Links::Plugins->get_plugin_user_cfg('Ratings');

my $tr_num = $opts->{'Top Rated Number'};

my $tr_min = $opts->{'Top Rated Minimum'};

my $tv_num = $opts->{'Top Vote Number'};

my $tv_min = $opts->{'Top Vote Minimum'};

my $br_num = $opts->{'Bottom Rated Number'};

my $br_min = $opts->{'Bottom Rated Minimum'};



but it does not seem to be taking the values I put in. ("Ratings" is the name of my Plugin, and all the field names and variables are correct) Any ideas?


dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Writing Plug In help In reply to
Nevermind! The problem MUST be elsewhere as I hard-coded in new values in the plugin itself, and it did not work.

Back to the drawing board!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Writing Plug In help In reply to
Whooo Hoooo!

I have it working!

Anyone interested in it, let me know- it is free! Cool
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Writing Plug In help In reply to
In Reply To:
Anyone interested in it, let me know- it is free! Cool

Congratulations Smile If you want to make it public, then you could send it to alex@gossamer-threads.com, and he should then add it to the download area that people can access in the plugins area :)

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!
Quote Reply
Re: [Andy] Writing Plug In help In reply to
Andy:

Thanks- I was thinking I would do just that. First, I want to make the "Bottom Links" an option, not a requirement- works good for me, but probably not everyone will want it. But I think making the Minimum Votes and the Number Returned is a good option for a lot of people!

Thanks for the encouragement- could not have done it without all the help I have been given here on this forum- Thanks to all!
dave

Big Cartoon DataBase
Big Comic Book DataBase