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

Top 10 Searches Plugin....

Quote Reply
Top 10 Searches Plugin....
I've made a plugin that requires Alex's Search Logger plugin and it basically shows the top10 searches using SSI. All has gone well except that SSI won't work when using a quesry string. Eg. the sub that displays the SSI code is in Top10.pm and is called top10ssi, therefore the SSI tag looks like....

...="/cgi-bin/admin.cgi?do=plugin&plugin=Top10&func=top10ssi...

......but this just wont work.....any ideas?

When I put the top10ssi sub in a seperate file and execute it, it works....is that what Im going to have to do?...Add another file with the SSI code in?

Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Hi,

How are you calling the SSI? If you use <!--#include, it will accept query string, but #exec doesn't.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Oh,

And I would also make a tag for it so people can put it easily on cgi generated pages:

<%Plugins::Top10::list%>

which would display them in CGI generated pages.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Ah thanks for the tip...I was using exec cgi!

Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Hm....

Ive made the plugin and it installed ok and the two admin options showed up perfectly, but when I add <%Plugins::Top10::top10ssi%> to search_result.html and perform a search, it just prints a 1 where the list should be.

Do I need to return the output rather than print it?


Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
ooooo I just added <%Plugins::Top10::top10ssi%> to home.html and rebuilt the directory and nph-build prints the top10 list as it's building.



Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
pretty sure that this
<%Plugins::Top10::top10ssi%>
is for cgi generated pages like search.cgi

you will need to use SSI for non cgi generated pages, like home.html

http://www.ASciFi.com/ - The Science Fiction Portal
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Yes I know..I added it to home.html as a test to see what would happen, thats why I started the post with oooooo.

But either way it doesn't want to work. It just prints a 1 as I said earlier....but it works with nph-build myteriously.

Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
oh, missed that. wish i could help.

http://www.ASciFi.com/ - The Science Fiction Portal
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Wish I could fix Smile

Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Welp..this is the sub that is clearly working......

http://odp.wiredon.net/...10&func=top10ssi

Just not with SSI or tags :(

Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
will it work via SSI if it is in a protected directory (like that is)? i don't know but we can't see it of course.

http://www.ASciFi.com/ - The Science Fiction Portal
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Hm thats possible...but the actual page with the SSI code isnt is a protected directory, only the sub with the code in, and I cant move that otherwise the plugin won't work.

Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Hi,

If called via SSI, you need to print the content type headers, and print the code.

If called as a <%tag%>, you need to return the output, not print it.

What I would do is:

Code:
use Links qw/$IN/;

sub top10ssi {
print $IN->header;
print _generate_top10();
}

sub top10 {
return _generate_top10();
}

sub _generate_top10 {
# figure out top10
return $top10;
}
Does that make sense? Let me know if it doesn't work for you..

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Thanks 8)

Working now....

I have another problem though (Im sorry to keep asking all these questions).

I can't seem to limit the list to only 10 terms...am I going to have to add maxterms or something like that to the SearchLogger table when the plugin is installed with 10 as the value or is there an easier way that I am over looking?

Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
To get the top 10, you should do something like:

my $search_db = $DB->table('SearchLog');
$search_db->select_options ('ORDER BY Results DESC', 'LIMIT 10');
my $sth = $search_db->select;
while (my $row = $sth->fetchrow_hashref) {
...
}

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Thanks.....Is it me or is this style of coding very complicated to learn.

Can you recommend any good websites with tutorials or are there any guides anywhere because I can only seem to find things like how to open and print to a file or how to process a form etc but there seems to be nothing for interacting with mysql.

Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
I think you'll find objects much easier once you get the hang of it. A great book on OO programing is Damian Conways Object Oriented Perl.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Thanks.

I guess it helps when you know code code back to front like you do. Im just gonna have to scan through the code and try to pick up tips. At the moment I only seem to be able to use your examples and modify them slightly....I will only be satisfied when I can write my own code.

Paul Wilson.
new - http://www.wiredon.net
Quote Reply
Re: Top 10 Searches Plugin.... In reply to
Alex perhaps a small suggestion, can some of these examples you are working through with us get written up in the plugin docs, would probably help quite a bit with a few more examples there.

http://www.ASciFi.com/ - The Science Fiction Portal
Quote Reply
Re: [Paul] Top 10 Searches Plugin.... In reply to
Hello,

I would like to obtain the list of the words scanned by SSI.

I do not understand the discussion.
Somebody has a solution?

Thank you for your assistance.

Mick