Gossamer Forum
Home : Products : Links 2.0 : Customization :

SOTD Errors - Plz help some one

Quote Reply
SOTD Errors - Plz help some one
I have been on this mod nearly all day and got absolutely no where fast.

I want to use templates and I will manually update links everyday, as I can use crontab.

Heres what I have done so far.

I have created sotd.cgi below and also the other scripts:-



####### sotd.cgi #########

#!/usr/bin/perl

$txtfile = '/home01/14479873/public_html/cgi-bin/archives/admin/sotd.txt';

# Required Librariers

# --------------------------------------------------------

eval {

($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /

($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \

require "links.cfg"; # Change this to full path to links.cfg if you have problems.

require "$db_lib_path/db_utils.pl";

require "$db_lib_path/links.def";

$build_use_templates ?

require "$db_lib_path/site_html_templates.pl" :

require "$db_lib_path/site_html.pl";

};

if ($@) {

print "Content-type: text/plain\n\n";

print "Error including libraries: $@\n";

print "Make sure they exist, permissions are set properly, and paths are set correctly.";

exit;

}

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

eval { &main; }; # Trap any fatal errors so the program hopefully

if ($@) { &cgierr("fatal error: $@"); } # never produces that nasty 500 server error page.

exit; # There are only two exit calls in the script, here and in in &cgierr.

sub main {

# --------------------------------------------------------

open (DB, "<$db_file_name") or &cgierr ("Can't Open DB: $db_file_name");

my @links = <DB>;

close DB;

my %rec = &array_to_hash (0, &split_decode ($links[int rand $#links]));

open (SOTD, ">$txtfile") or &cgierr ("Can't Open FILE: $txtfile. Reason: $!");

print SOTD &site_html_sotd (%rec);

close SOTD;

$ENV{'REQUEST_METHOD'} and print "Content-type: text/plain\n\n";

print "ID: $rec{$db_key} Title: $rec{'Title'}\n";

}



######



Also

added

site_html.pl
Code:
sub site_html_sotd {
# --------------------------------------------------------
# This routine determines how the sotd link will look like.
#
my %rec = @_;
my ($output);
$output = qq~
<a href="$rec{'URL'}">$rec{'Title'}</a><br>
~;
return $output;
}

site_html_templates.pl
Code:
sub site_html_sotd {
# --------------------------------------------------------
# This routine determines how the sotd link will look like.
#
my %rec = @_;

# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});

return &load_template ('sotd.html', {
%rec,
%globals
});
}

sotd.html
Code:
<a href="<%URL%>"><%Title%></a><br> In my home.htmlI have tried adding <!--#include virtual="/cgi-bin/archives/admin/sotd.txt"--> or
<!--#exec cgi="/cgi-bin/archives/admin/sotd.pl" --> When I run the cgi script from my browser I get =>ID: 2 Title: testlink Where am I going wrong, i want the sotd to show up on my home page, but I get nothing. Plz help someone.
Quote Reply
Re: [stu2000] SOTD Errors - Plz help some one In reply to
I have also tried adding Elliots mod to the above code but still no joy. Code added

1) Insert the following codes into your site_html_templates.pl file:

Code:
sub siteofday {
# ---------------------------------------------
# Displays the number of accounts

open (INC, "/home01/14479873/public_html/cgi-bin/archives/admin/sotd.txt") or return "Can't find include file:
Site of Day file{$_}";
return join ("", <INC> );
}

2) Then add the following global variable in the site_html_templates.pl file:

Code:
siteofday => &siteofday,

3) Insert the following tag in your home.html or category.html template files:

Code:
<%siteofday%> I now get the following error ---Unknown tag: URL

Last edited by:

stu2000: Mar 25, 2002, 6:50 PM
Quote Reply
Re: [stu2000] SOTD Errors - Plz help some one In reply to
This is what is inside my sotd.txt file

<a href="Unknown tag: URL">testlink</a><br>



its obviously this thats causing the problem but what changes are necessary to fix it:-

sotd.html
Code:
<a href="<%URL%>"><%Title%></a><br>

Last edited by:

stu2000: Mar 25, 2002, 7:13 PM
Quote Reply
Re: [stu2000] SOTD Errors - Plz help some one In reply to
Please check that the siteofday variable is available

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] SOTD Errors - Plz help some one In reply to
I have managed to fix it.

I changed my sotd.html to read

<a href="<%db_cgi_url%>/detail.cgi?ID=<%ID%>" target=newwin><%Title%></a>
<%if isPick%>
<font color="#FF9900" size="2"> Pick</font>
<%endif%>
<%if isPopular%>
<font color="red" size="2"> Cool</font>
<%endif%>
<br>
<%Description%>
<br>
<b>Rating:</b> <a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>"><%Rating%></a> <b>Votes:</b> <%Votes%> <b>Downloaded:</b> <%Hits%>.

then went back into sotd.cgi then rebuilt links worked ok.