Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Lastlink SSI

(Page 2 of 2)
> >
Quote Reply
Re: [reenee] Lastlink SSI In reply to
Hello anybody ?

Did anyone successful run the mod with result 5 lastlink with the mod below ? I did try at 2 server with a different database style, its only show one link....

Please help .....

#!/usr/bin/perl
#================================

use strict;
use lib '/home/worldbar/public_html/directories/cgi-bin/admin';
use Links qw/$DB $IN/;
Links::init('/home/worldbar/public_html/directories/cgi-bin/admin');
use Links::SiteHTML;

local $SIG{__DIE__} = \&Links::fatal;
main();

#================================

sub main {
#---------------------------------------------------
# Display the newest link.

my $tab = $DB->table('Links');
$tab->select_options('ORDER BY ID DESC', 'LIMIT 5');

my $rec = $tab->select( { isValidated => 'Yes' } )->fetchrow_hashref;


print $IN->header();
print Links::SiteHTML::display('link', $rec);

}
Quote Reply
Re: [reenee] Lastlink SSI In reply to
Its because fetchrow_hashref does what it says ... fetchrow....so it will only print one record.

Change sub main() to:

Code:
sub main {
#---------------------------------------------------
# Display the newest link.

my ($sth,$tab,$output);

$tab = $DB->table('Links');
$tab->select_options('ORDER BY ID DESC', 'LIMIT 5');
$sth = $tab->select( { isValidated => 'Yes' } );
while (my $rec = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $rec);
}

print $IN->header();
print $output;

}

Last edited by:

RedRum: Mar 12, 2002, 12:29 PM
Quote Reply
Re: [RedRum] Lastlink SSI In reply to
Yes, Its work, Thanks u so much Paul..

Blush
Quote Reply
Re: [reenee] Lastlink SSI In reply to
Thats ok! Angelic
Quote Reply
Re: [RedRum] Lastlink SSI In reply to
Hi Paul,

Somebody from my web hosting account just warn me becoz the mod below take a lot of memory & cpu resources, so .. just back to my ealier post regarding how to make the lastlink mod below is run it with cron and make it writing to file, then i can import the file thru SSI.

Please help and thank you so much.

#!/usr/bin/perl
#================================

use strict;
use lib '/home/worldbar/public_html/directories/cgi-bin/admin';
use Links qw/$DB $IN/;
Links::init('/home/worldbar/public_html/directories/cgi-bin/admin');
use Links::SiteHTML;

local $SIG{__DIE__} = \&Links::fatal;
main();

#================================

sub main {
#---------------------------------------------------
# Display the newest link.

my ($sth,$tab,$output);

$tab = $DB->table('Links');
$tab->select_options('ORDER BY ID DESC', 'LIMIT 5');
$sth = $tab->select( { isValidated => 'Yes' } );
while (my $rec = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $rec);
}

print $IN->header();
print $output;

}
Quote Reply
Re: [reenee] Lastlink SSI In reply to
>>
Somebody from my web hosting account just warn me becoz the mod below take a lot of memory & cpu resources,
<<

That is the funniest thing I've heard. How on earth did your host come to that conclusion?

The code does one mysql query taking milliseconds. There is nothing wrong with it.

Maybe you should get your host to execute this code:

while() { print 1 }

Last edited by:

RedRum: Mar 13, 2002, 3:02 AM
Quote Reply
Re: [RedRum] Lastlink SSI In reply to
Yes, its true, may be because i run the lastlink.cgi file at my frontpage, and for sure my visitor is mostly 1 - 2 visitors in every second, so hosting company just advice to run it thru SSI (include virtual) instead of directly run it from CGI by using exec, well ..just obey instead of my account gonna block Frown

Please help Paul.
Quote Reply
Re: [reenee] Lastlink SSI In reply to
Isn't it just a matter of adding the following into your page?

<!--#exec cgi="/path/to/script.cgi" -->

>>so hosting company just advice to run it thru SSI (include virtual) instead of directly run it from CGI by using exec,<<

Either way the script has to be executed as well as parsed if it is called using SSI. I'd have thought that takes more processing.

Last edited by:

RedRum: Mar 13, 2002, 3:17 AM
Quote Reply
Re: [reenee] Lastlink SSI In reply to
Hi,

Shows your hosting company does not know what they are talking about. =) Using SSI or running .cgi directly is the same amount of overhead.

You could setup a cron job that runs once an hour and saves the top id's to a html file, and then use SSI to include the html page, that would reduce the overhead considerably.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Paul] Lastlink SSI In reply to
Hi Paul,

I was reading this post and I was wondering if you could help me. Or anyone else reading. I was able to get this script to display my latest links on home.html, *thanks for the code* but instead of it printing out the links.html template with the latest links, how can I display only the 'Title' and 'Location' (e.g. dir1:subdir9)?

What I would like to do is make up a new template like lastten.html and have home.html run a loop that will display the last ten links added. This will display on home.html and will be look like the table I make in lastten.html instead of what my tables look like in links.html. *Not sure if that makes sense*

Thank you,

Eddie
Quote Reply
Re: [eddie123] Lastlink SSI In reply to
Just change

$output .= Links::SiteHTML::display('link', $rec);

to

$output .= Links::SiteHTML::display('lastten', $rec);
Quote Reply
Re: [Alex] Lastlink SSI In reply to
In Reply To:

You could setup a cron job that runs once an hour and saves the top id's to a html file, and then use SSI to include the html page, that would reduce the overhead considerably.


Anyone know how make this html file (template) and configure the cgi files (nph_build.cgi...) to output the top id's with the "lastlink global"??

Thank you in advance!!

-----------------------
Nomada

Last edited by:

Nomada: Aug 9, 2003, 4:11 AM
> >