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.
Quote Reply
Re: [Rob1] Comment 4 mod problem.... In reply to
Note: based on one of the threads, I tried setting it up this way:



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'});

######comments
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;
#####end of comments#####

return &load_template ('link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
totals => $totals,
%rec,
%globals
});
}

sub site_html_home {



This builds, but then I get:

JM test 1 new (Added: <Úte%> Hits: 1 Rating: 5.00 Votes: 1) Rate It < a href = "<Û_cgi_url%>/comments4l.cgi?function=display&LID=3">Comments[/url]
<Þscription%>


For my links. Sigh...
Quote Reply
Re: [Rob1] Comment4l $total problem In reply to
Did you ever figure how to get the total number of comments to work?

I can't figure where to place totals => $totals.

Everything else works beautifully.

I would like to add a button for the user to jump back to the category page. That is for another thread.
...steven
MINI Links
BMW 318ti Registry
Quote Reply
Re: [steven1214] Comment4l $total problem In reply to
Unsure
I am still having a hard time getting the number of comments to appear.
I have searched and read the forum. I'm stumped.
I'm sure it's something obvious to someone.

Can someone take a look at my site_html_templates.pl file?

Also included is Bobsie's 3 level of new graphics mod.

My links.html includes
Code:
<span class="descript">
<a href = "<%db_cgi_url%>/comments4l.cgi?function=display&LID=<%ID%>">Your comments</a><%totals%> </span>
<%if Description%>
<span class="descript"> - <%Description%> </span>
<%endif%>

Any help is greatly appreciated.
...steven
MINI Links
BMW 318ti Registry
Quote Reply
Re: [steven1214] Comment4l $total problem In reply to
In his comments 2 he had the following for sub site_html_link

Code:
return &load_template ('link.html', {
new_mod_img => $new_mod_img,
detailed_url => "$build_detail_url/$rec{'ID'}$build_extension",
%rec,
totals => $totals,
%globals
});


seems reasonable to me since I see where he opens the comments file; then he compares the current links record ID to the comments record ID and increments the total variable if they are the same.

Code:
if ($rec{'ID'} eq $counter) { $totals++ ; }


but hey, I always thought perl was something found in an oyster! Crazy


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."