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

Inherit subroutine in plugin

Quote Reply
Inherit subroutine in plugin
Is it possible for a plugin hook to call a routine in the original code, so I do not have to maintain a local copy in my plugin code?

For example, in my plugin.pm file I have this:

sub search_results_hook {
return search();

sub search {
# ------------------------------------------------------------------
# Do the search and print out the results.
my $results = query();
if (defined $results->{error}) {
print $IN->header();
$results->{main_title_loop} = Links::Build::build('title', Links::language('LINKS_SEARCH'), "$CFG->{db_cgi_url}/search.cgi");
print Links::SiteHTML::display('find_entertainment', $results);
else {
print $IN->header();
$results->{main_title_loop} = Links::Build::build('title', Links::language('LINKS_SEARCH_RESULTS'), "$CFG->{db_cgi_url}/search.cgi");
print Links::SiteHTML::display('search_results', $results);
if ($CFG->{debug_level} > 1) {
print "<blockquote><pre>", GT::SQL->query_stack_disp , "</pre></blockquote>";

The routine search() is a copy from GTs 'Search.pm' with 2 minor edits.
1) I do not call plugin hook or I would have a circular reference.
2) On error, I want to return to my template, not search.html

Now the question :-)
The routine query() is an exact copy of the routine from GTs code.
I have a local copy in my code. If I delete it, I get errors.
Is there a way to call query() from my code if query() resides in Search.pm?

RGB World, Inc. - Software &amp; Web Development.
Quote Reply
Re: [rgbworld] Inherit subroutine in plugin In reply to
My guess would be

my $results = Links::User::Search::query();

You may need to include Links::User::Search; at the top of the file.