Gossamer Forum
Home : Products : Links 2.0 : Customization :

Help! 3 New Levels Graphics mod Please look at this.

Quote Reply
Help! 3 New Levels Graphics mod Please look at this.
Hi! Just installed the 3-new levels mod. Thanks Bobsie! And in advance to anyone who could help me debug this.

I'm using templates.
Other mod using:
yahoo style sub catetories
password security (modify link)
email password (if you forget)

No errors in building pages.
View links in admin shows newly added field.

Problem: No graphics show up for Update or any level of New. Tried URL and PATH for img src. and still not working.

I've gone over it a few times. Is there a certain area I should be looking at more carefully?

Here are the parts of the codes I have changed...listed according the the order in the instructions.

links.def
Code:
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
Password => [14, 'alpha', 10, 10, 1, '', ''],
DateAdded => [15, 'date', 15, 15, 0, \&get_date, ''],
);
links.def (next part)
Code:
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_password = 14; $db_dateadded = 15;

add.cgi, sub process_form
Code:
# This will set system fields like Validated to their proper values.
foreach $key (keys %add_system_fields) {
$in{$key} = $add_system_fields{$key};
}

# Set modified and added date variables to today's date.
$in{$db_cols[$db_dateadded]} = $in{$db_cols[$db_modified]} = &get_date;

open (ID, "<$db_links_id_file_name") or &cgierr("error in process_form. unable to open id file: $db_links_id_file_name. Reason: $!");
$in{$db_key} = <ID> + 1; # Get next ID number
close ID;

# Validate the form input..
$status = &validate_record(%in);
if ($status eq "ok") {

modify.cgi, sub process_form
Code:
# Print out the modified record to a "modified database" where it is stored until
# the admin decides to add it into the real database. Ensure we retain the original
# date the record was added.
$in{$db_cols[$db_dateadded]} = $original{'DateAdded'};

STEP 5 - modify links.db (results of add_date.pl)
Code:
Opening links.db for reading. . .
Opening links2.db for writing. . .
Processing database records. . .
Done, closing database files. . .
Links database now has DateAdded field completed.
It is stored in links2.db

6. nph-build.cgi - sub build_update_newpop
Code:
# Now go through the links database and update new links, and
# add the hits.
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
if ((!$values[$db_date]) &#0124; &#0124; (!$values[$db_dateadded])) {
print "Warning: No date for line: $_. Skipping..\n" and next LINE;
}

# Calculate days old and then mark new.
$days = &days_old($values[$db_dateadded], $date);
($days <= $db_new_cutoff) and ($new_records{$values[$db_key_pos]}++);

sub build_category_information
Code:
# We also need to intialize a links counter for the category,
# flags for new or modified links, and date fields (set to 1-Jan-1990)
# in case there are no links in the category to get a date from.
$stats{$name}[0] = 0; # storage for number of links
$stats{$name}[1] = "1-Jan-1990"; # storage for date modified
$stats{$name}[2] = "1-Jan-1990"; # storage for date added
$stats{$name}[3] = "No"; # modified record flag
$stats{$name}[4] = "No"; # new record flag

sub build_stats
Code:
# Store the most recent modification date for links in this category.
if ((!$stats{$cat}[1]) &#0124; &#0124;
&compare_dates($values[$db_modified], $stats{$cat}[1])) {
$stats{$cat}[1] = $values[$db_modified];
}
# Store the most recent add date for links in this category.
if ((!$stats{$cat}[2]) &#0124; &#0124;
&compare_dates($values[$db_dateadded], $stats{$cat}[2])) {
$stats{$cat}[2] = $values[$db_dateadded];
}
# Is (modified) Date more recent than DateAdded?
if (&compare_dates($stats{$cat}[1], $stats{$cat}[2])) {
# Yes, so does it qualify as an "updated" link?
if (&days_old($stats{$cat}[1]) <= $db_new_cutoff) {
# Yes, so set updated link flag for this category.
$stats{$cat}[3] = "Yes";
}
}
# Is this a new link?
if (&days_old($stats{$cat}[2]) <= $db_new_cutoff) {
# Yes, so set new link flag for this category.
$stats{$cat}[4] = "Yes";
}

pop (@categorylist);
$cat = join("/", @categorylist);
}
}
}
close DB;

sub build_new_page
Code:
# Now we go through all the new_links (which are organized by category), and
# build the html in array indexed by date then category.
$total = 0;
CATEGORY: foreach $category (sort keys %new_links) {
LINK: for ($i = 0; $i < ($#{$new_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$new_links{$category}});
${$link_output{$tmp{'DateAdded'}}}{$category} .= &site_html_link (%tmp) . "\n";
$span_totals{$tmp{'DateAdded'}}++;
}
}

This next step I was kinda confused:
Here's what I have:
site_html.pl
Code:
##########################################################
## Globals ##
##########################################################
# You can put variables here that you would like to use throughout
# the site.

$date = &get_date;
$time = &get_time;

$new_1 = qq|<img src="/usr/home/alien1/www/webmaster/images/new_1.gif" border="0" width=34 height=12 alt="New0-2" align="absmiddle">|;

$new_3 = qq|<img src="/usr/home/alien1/www/webmaster/images/new_3.gif"
border="0" width=34 height=12 alt="New3-7" align="absmiddle">|;

$new_7 = qq|<img src="/usr/home/alien1/www/webmaster/images/new_7.gif"
border="0" width=34 height=12 alt="New8-14" align="absmiddle">|;

$updated = qq|<img
src="/usr/home/alien1/www/webmaster/images/updated.gif"
width=34 height=12 border=0 alt="Updated" align="absmiddle">|;

# The default DTD is HTML 4 strict. You can check this using the W3's validator
# http://validator.w3.org/

still site_html.pl - sub site_html_link
Code:
my (%rec) = @_;
my $days_old;
my $new_mod_img = "";

** QUESTION: I cannot find THIS step in my site_html.pl IS THIS THE PROBLEM?
Code:
foreach $subcat (sort @subcat) {
my $mod = $stats{"$subcat"}[3];
my $new_add = $stats{"$subcat"}[4];
($description) = @{$category{$subcat}}[2];

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
# $mod = $stats{"$subcat"}[1];

next step in site_html.pl
Code:
# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq~<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> ~;
if ($new_add eq "Yes") {
$days_old = &days_old($stats{"$subcat"}[2]);
if ($days_old <= 2) { $output .= qq| $new_1|; }
elsif ($days_old <= 7) { $output .= qq| $new_3|; }
elsif ($days_old <= 14) { $output .= qq| $new_7|; }
}
if ($mod eq "Yes") { $output .= qq~ $updated~; }
$output .= qq~</dt>~;
$output .= qq~<dd><span class="descript">$description </span></dd>~ if (!($description =~ /^[\s\n]*$/));
$output .= qq~</dl>~;

}

Now on to my site_html_templates_html
Should I add something here?
Code:
# You can put variables here that you would like to use in any
# of your templates.

%globals = (
date => &get_date,
time => &get_time,
db_cgi_url => $db_cgi_url,
build_root_url => $build_root_url,
site_title => $build_site_title,
css => $build_css_url,
banner => ''
);
sub site_html_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.

my %rec = @_;
my $days_old;
my $new_mod_img = "";

# Set new and pop to either 1 or 0 for templates.
# The record is either New, Updated, or neither. Only a New or Updated
# graphic can be displayed for a link, but never both.
# First, check to see if the link is new.
if ($rec{'isNew'} eq "Yes") {

# Calculate age of link based on Date Added, not Date Modified.
$days_old = &days_old($rec{'DateAdded'});

# Display appropriate New graphic based on age of link.
if ($days_old <= 2) { $new_mod_img = $new_1; }
elsif ($days_old <= 7) { $new_mod_img = $new_3; }
elsif ($days_old <= $db_new_cutoff) { $new_mod_img = $new_7; }
}

# If the link is not new, check to see if it has been updated.
elsif (&compare_dates($rec{'Date'}, $rec{'DateAdded'})) {

# Calculate age of link based on Date Modified, not Date Added.
$days_old = &days_old($rec{'Date'});
if ($days_old <= $db_new_cutoff) { $new_mod_img = qq~ $updated~; }
}

($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});

return &load_template ('link.html', {
new_mod_img => $new_mod_img,
detailed_url => "$build_detail_url/$rec{'ID'}$build_extension",
%rec,
%globals
});
}[/code]
still site_html_templates.pl
sub site_html_print_cat
Code:
my (@subcat) = @_;
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);
my ($half) = int (($#subcat+2) / 2);

# Print Header.
$output = qq|<div class="margin"><table width="80%" border="0" cellspacing="0" cellpadding="0"><tr><td class="catlist" valign="top">\n|;

foreach $subcat (sort @subcat) {
my $mod = $stats{"$subcat"}[3];
my $new_add = $stats{"$subcat"}[4];
($description) = @{$category{$subcat}}[2];

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
# $mod = $stats{"$subcat"}[1];

last step in site_html_templates.pl
Code:
# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
if ($new_add eq "Yes") {
$days_old = &days_old($stats{"$subcat"}[2]);
if ($days_old <= 2) { $output .= qq| $new_1|; }
elsif ($days_old <= 7) { $output .= qq| $new_3|; }
elsif ($days_old <= 14) { $output .= qq| $new_7|; }
}
if ($mod eq "Yes") { $output .= qq~ $updated~; }

$output .= qq|</dt>|;

and finally, my links.html in the templates directory
Code:
<ul><li><a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>

<%if Description%>
<span class="descript">- <%Description%></span>
<%endif%>

<%if new_mod_img%>
<%new_mod_img%>
<%endif%>

<%if isPopular%>
<small><sup class="pop">pop</sup></small>
<%endif%>

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

</ul>

I've gone over this serveral times, including this last time I checked as I went along to paste the codes in here.

Quote Reply
Re: Help! 3 New Levels Graphics mod Please look at this. In reply to
Well, for starters, are you using templates or not? If so, you don't really need any of those changes to site_html... second, I don't see that you have defined $new_1, _3 and _7 in the globals section of site_html_templates (you did get that step in site_html). As a general rule, site_html NEVER gets called if you are using templates... its one or the other.

[Eliot: we posted over each other...]
------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)

[This message has been edited by oldmoney (edited January 20, 2000).]
Quote Reply
Re: Help! 3 New Levels Graphics mod Please look at this. In reply to
Here are the problems I found:

1) Delete the following codes from sub build_category_information:

Code:
$stats{$name}[2] = "1-Jan-1990"; # storage for date added
$stats{$name}[3] = "No"; # modified record flag

2) The global variables (img variables) need to go in your site_html_templates.pl file above the global variable hash section.

3) All the codes you placed in the sub site_html_link routine in the site_html.pl need to STAY in the sub site_html_link routine in the site_html_templates.pl file. (BTW: Since you are using templates, you do NOT need site_html.pl file UNLESS you have installed some mods like the Site of the Day.)

4) In your template file, you need to use the following tags:

Code:
<%if isNew%>
<%new_mod_img%>
<%endif%>

Hope this helps...I would try looking at the instructions more carefully.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------





Quote Reply
Re: Help! 3 New Levels Graphics mod Please look at this. In reply to
heh! forgot.

Thanks money!




Nelson
heheh..


[This message has been edited by Nelson (edited January 21, 2000).]
Quote Reply
Re: Help! 3 New Levels Graphics mod Please look at this. In reply to
Of course I was joking... hope you got it fixed.
Quote Reply
Re: Help! 3 New Levels Graphics mod Please look at this. In reply to
Thank you, Eliot!


Quote Reply
Re: Help! 3 New Levels Graphics mod Please look at this. In reply to
See if I answer one of your posts again... j/k
Quote Reply
Re: Help! 3 New Levels Graphics mod Please look at this. In reply to
Yes...we did, oldmoney.

Sorry about that.

Glad you got this fixed.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
http://www.anthrotech.com
Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
----------------------