Gossamer Forum
Quote Reply
plugin problems
Hi All,

I'm trying to write a plugin and am running into problems. I have a hook in place :

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

I've added a column in the links_Links table called directory. I want to utilise the existing search program to search the 'Links' table using a value for 'directory' and the query passed in via the search box e.g select * from links_Links where <search_criteria> and $directory = <directory_value>.

Can someone point me in the right direction on how to do this. I tried modifying the existing search function, but this did not work.


Also, when I run the plugin the results page contains the message:

Your search returned Unknown Tag: 'cat_hits' categories and Unknown Tag: 'link_hits' Links


The code I've written thus far is as follows:

sub search {
# -------------------------------------------------------------------
# This subroutine will get called whenever the hook 'search_link_hook'
# is run. You should call GT::Plugins->action ( STOP ) if you don't
# want the regular code to run, otherwise the code will continue as
# normal.
#

my @args = @_;


my $directory = $IN->param('directory');
my $query = $IN->param('query');
my $db = $DB->table('Links');
#my $full_query = $query . ' and directory = $directory';
my $results = $db->get ( $query,GT::SQL::Condition->new ( 'directory','=',$directory ));

print $IN->header;
if (defined $results->{error}) {
print $IN->header();
print Links::SiteHTML::display ('search', $results);
}

else {
print $IN->header();
print Links::SiteHTML::display ('search_results', $results);
}
if ($CFG->{debug_level} > 1) {
print "debug > 1<blockquote><pre>", GT::SQL->query_stack_disp , "</pre></blockquote>";
}

GT::Plugins->action ( STOP );
return @args;

}


# Always end with a 1.
1;


TIA


Dean

Quote Reply
Re: [wobbly] plugin problems In reply to
Hi,

Can you not simply do:

http://yoursite/cgi-bin/search.cgi?query=foo&directory=bar

to find a list of sites that match the query, and have directory set to bar?

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] plugin problems In reply to
Alex,

You know sometimes you can't see the wood for the trees.........

Thanks

Dean