Gossamer Forum
Home : Products : Links 2.0 : Customization :

Comment 4 mod problem....

Quote Reply
Comment 4 mod problem....
This is based on the ‘Comments 4 lite' mod and his detailed instructions:
http://cgi-resource.co.uk/pages/comment4l.html

Forgive the length of this- it's as much for anyone else having trouble as it is for me- so I kinda run through the basics where stupid mistakes may occur. I've read the tons of thread on this- I'm still having a problem!

What I know I (probably) did right- uploaded all files, IN ASCII, to appropriate directories. Had to chmod cgi to 755, data directory files to 666, template directory files to 666.

Went into links.cfg and set correct paths.

Went into admin_html.pl and the "sub html_navigation" added info for administration screen. (It's easy to figure out where to plop it down- I just made it the last paragraph of text).

HERE's where I get lost- in changes to: "site_html_templates.pl"

1. Add the two subroutines- no problem. I put them as the first two subroutines, and don't think it should be an issue.

(Thus I inserted the two new subs right after: global info and right before the "site_html_link" subroutine.)

And now I'm lost!

Instructions say:

Quote:
In site_html_link add:
my (@values, $counter, $totals); $counter = 0; open (DB, "<$db_comments_name") or &cgierr("unable to open database: $db_comment_name. Reason: $!"); LINE: while (<DB> ) { /^#/ and next LINE; # Skip comment Lines. /^\s*$/ and next LINE; # Skip blank lines. chomp; @values = &split_decode ($_); $counter = $values[1]; if ($rec{'ID'} eq $counter) { $totals++; } } close DB;
Then at the bottom of the sub add:
totals => $totals,
In link.html add:
< a href = "<%db_cgi_url%>/comments4l.cgi?function=display&LID=<%ID%>">Comments</a>< %totals%>


OK- two issues:

1. I assume when it says to add in ‘link.html'- that's the file! I added it thusly:

WAS:

<small class="date">(Added: <%Date%> Hits: <%Hits%> Rating: <%Rating%> Votes: <%Votes%>) <a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate It</a></small><br>

Modified:

<small class="date">(Added: <%Date%> Hits: <%Hits%> Rating: <%Rating%> Votes: <%Votes%>) <a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate It</a> < a href = "<%db_cgi_url%>/comments4l.cgi?function=display&LID=<%ID%>">Comments</a><%totals %></small><br>

That seems right.

2. I think I'm screwing up where to add into the site_html_link sub inside "site_html_templates.pl".

Here's what I tried:


sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should 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 ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
%rec,
%globals
});
########Added stuff##############
my (@values, $counter, $totals);
$counter = 0;
open (DB, "<$db_comments_name") or &cgierr("unable to open database: $db_comment_name. Reason: $!");
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$counter = $values[1];
if ($rec{'ID'} eq $counter) {
$totals++;
}
}
close DB;


totals => $totals,

#####End of Mod########

}

sub site_html_home {
etc....





This doesn't work- generates no error in ‘build', but now I get : "Unkown Tag: totals" instead of links to sites.

When I move the totals=> $totals, to OUTSIDE the sub, (after the final "}" ), build generates this error:

Error including libraries: syntax error at /home/daysfanf/public_html/cgi- bin/links2/admin/site_html_templates.pl line 123, near "sub site_html_home " Compilation failed in require at /home/daysfanf/public_html/cgi-bin/links2/admin/nph-build.cgi line 33.

HELP! I'm at a loss. I'm thinking the error HAS to be where I'm placing that bit of script in sub site_html_link - but I simply don't know how to fix it. Could someone look over this to see where exactly I'm going wrong? I've read through the MANY threads on this, and I've managed to install a couple of other mods, but I simply don't know the coding well enough to see my mistakes! Sorry for asking when it's been discussed to death- but the threads leapt around, and I simply got lost.
Subject Author Views Date
Thread Comment 4 mod problem.... Rob1 3219 Mar 20, 2002, 4:03 PM
Post Re: [Rob1] Comment 4 mod problem....
Rob1 3174 Mar 20, 2002, 4:27 PM
Thread Re: [Rob1] Comment4l $total problem
steven1214 3065 Feb 2, 2003, 6:31 PM
Thread Re: [steven1214] Comment4l $total problem
steven1214 3082 Feb 4, 2003, 8:54 PM
Post Re: [steven1214] Comment4l $total problem
esm 3071 Feb 5, 2003, 1:51 AM