Gossamer Forum
Home : Products : Others : Gossamer Community :

community plugin

Quote Reply
community plugin
I'm experiementing with a plugin in community and I noticed that there is no Plugins.pm file containing the function:

get_plugin_user_cfg

like there is in links in the admin / links directory in GLinks.

So if I want to emulate this statement:

Code:
my $myPageCFG = Links::Plugins::get_plugin_user_cfg('MyPlugin');

what would be the best way to do this?

Thanks,



- Jonathan
Quote Reply
Re: [jdgamble] community plugin In reply to
So I tried copying the sub routine from links's plugin.pm file and putting it at the bottom of my plugin file in community, but it does not bring back any of the records. I also of course changed the path to fit for community.

Code:
sub get_plugin_user_cfg {
# --------------------------------------------------------------
# Returns the user config hash for a given plugin.
#
# my $class = ($_[0] eq 'Links::Plugins') ? shift : '';
my $plugin_name = shift || return;
my $cfg = GT::Plugins->load_cfg ($CFG->{path_private} . '/lib/Community/Plugins' );
exists $cfg->{$plugin_name} or return {};
(ref $cfg->{$plugin_name}->{user} eq 'ARRAY') or return {};
my $opts = {};
foreach my $opt (@{$cfg->{$plugin_name}->{user}}) {
$opts->{$opt->[0]} = $opt->[1];
}
return $opts;
}

This doesn't seem to bring back anything. If I can't pull the information out of the Plugin Options area, then any plugin in community is pretty pointless! Any ideas?

- Jonathan
Quote Reply
Re: [jdgamble] community plugin In reply to
Okay, so I finally got it to work!!!

I found the sub routine I was looking for in Community::Web::Plugins.

I also found that, unlike links, you need to require the Plugins module in your new plugin.

Nethertheless it works great now.

wah who...

- Jonathan