Gossamer Forum
Home : Products : Links 2.0 : Customization :

NEW Related Links MOD

Quote Reply
NEW Related Links MOD
I'm trying to compile a working version of the Related Links mod posted in other topics. Here is what I have so far, but it is not working. Any ideas?

1.) In links.def I added:
Related => [23, 'alpha', 40, 500, 0, '', ''],


2. I changed nph-build.cgi to this:

sub build_detailed_view {
# --------------------------------------------------------
# This routine build a single page for every link.
#
my (@values, $id, %rec, $related, $count);
if ($build_detail_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
print "\t";


$related = "";
@rel = split(/~/, $rec{'related'});
foreach $related_link (@rel) {
my (%rel) = &get_record ($related_link);
$related .= &site_html_related_link (%rel);
}




open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
%rec = &array_to_hash (0, @values);
$title_linked = &build_linked_title ("$rec{'Category'}/$rec{'Title'}");
open (DETAIL, ">$build_detail_path/$id$build_extension") or &cgierr ("Unable to build detail page: $build_detail_path/$id$build_extension. Reason: $!");
print DETAIL &site_html_detailed (%rec, $related);
close DETAIL;
$use_html ?
print qq~<a href="$build_detail_url/$id$build_extension" target="_blank">$id</a> ~ :
print qq~$id ~;
(++$count % 10) or print "\n\t";
}
close DB;
print "\n";
}


3. In site_html_templates.html:


sub site_html_detailed {
# --------------------------------------------------------
# This routine will build a single page per link. It's only
# really useful if you have a long review for each link --
# or more information then can be displayed in a summary.
#

my %rec = @_;

return &load_template ('detailed.html', {
description => $description,
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
total => $total,
title_linked => $title_linked,
rate_img => &get_rating_image($rec{'Rating'}),
related => $related, # This will created related links Added April 18th, 2001



%rec,
%globals
} );
}


sub site_html_related_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.
my %rel = @_;

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

return &load_template ('link_related.html',
{ detailed_url => "$db_detailed_url/$rel{'ID'}$build_extension",
title => $title,

%rel,
%globals

});}


4. I added a templated called link_related.html:

<ul><li><%Title%></li></ul>


Am I missing anything because I still get nothing when I add <%related%> or <%Related%> to the detailed page.




Quote Reply
Re: Related Links MOD In reply to
$related = "";
@rel = split(/~/, $rec{'related'});
foreach $related_link (@rel) {
my (%rel) = &get_record ($related_link);
$related .= &site_html_related_link (%rel);
}


Should be moved further down underneath:

%rec = &array_to_hash (0, @values);




Good Luck!

Glenn
Host Links
http://cgi-resource.co.uk/links
Quote Reply
Re: Related Links MOD In reply to
Thanks for the help Glenn but it's still not working correctly.

in the detailed.html template

<%related%> produces nothing

and

<%Related%> simply produces the value of the field.



Again, any help is really appreciated!

Quote Reply
Re: Related Links MOD In reply to
Sorry:

$related = "";
@rel = split(/~/, $rec{'related'});
foreach $related_link (@rel) {
my (%rel) = &get_record ($related_link);
$related .= &site_html_related_link (%rel);
}


Shoul be:

$related = "";
@rel = split(/~/, $rec{'Related'});
foreach $related_link (@rel) {
my (%rel) = &get_record ($related_link);
$related .= &site_html_related_link (%rel);
}



Good Luck!

Glenn
Host Links
http://cgi-resource.co.uk/links
Quote Reply
Re: Related Links MOD In reply to
Thanks again Glenn, but it's still not working right. This actually introduced a new problem... it only builds the first detailed page. Sounds a lot like the other thread on this huh? Thanks for all your help.

Here is what build_detailed_view looks like in nph-build.cgi now:


sub build_detailed_view {
# --------------------------------------------------------
# This routine build a single page for every link.
#
my (@values, $id, %rec, $related, $count);
if ($build_detail_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
print "\t";

open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
%rec = &array_to_hash (0, @values);
$title_linked = &build_linked_title ("$rec{'Category'}/$rec{'Title'}");
$related = "";
@rel = split(/~/, $rec{'Related'});
foreach $related_link (@rel) {
my (%rel) = &get_record ($related_link);
$related .= &site_html_related_link (%rel);
}
open (DETAIL, ">$build_detail_path/$id$build_extension") or &cgierr ("Unable to build detail page: $build_detail_path/$id$build_extension. Reason: $!");
print DETAIL &site_html_detailed (%rec, $related);
close DETAIL;
$use_html ?
print qq~<a href="$build_detail_url/$id$build_extension" target="_blank">$id</a> ~ :
print qq~$id ~;
(++$count % 10) or print "\n\t";
}
close DB;
print "\n";
}

Quote Reply
Re: Related Links MOD In reply to
Any Ideas?

Quote Reply
Re: Related Links MOD In reply to
No Idea anybody?

Quote Reply
Re: Related Links MOD In reply to
I played around with the variables a bit and renamed related to relatedlink and actually got the script to print out a detailed page w/ the correct title and link.

However, I discovered this: nph-build.cgi will stop building detailed pages after the first one that has any related links.

What gives? AHHHH!

Quote Reply
Re: Related Links MOD In reply to
Here is what I've done:

1.) In links.def added:

Relatedlink => [23, 'alpha', 40, 500, 0, '', ''],


2.) In site_html_templates.html:



sub site_html_detailed {
# --------------------------------------------------------
# This routine will build a single page per link. It's only
# really useful if you have a long review for each link --
# or more information then can be displayed in a summary.
#

my %rec = @_;

return &load_template ('detailed.html', {
description => $description,
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
total => $total,
title_linked => $title_linked,
rate_img => &get_rating_image($rec{'Rating'}),
relatedlink => $relatedlink, # This will created related links Added April 18th, 2001



%rec,
%globals
} );
}





sub site_html_related_link {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.
my %rel = @_;

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

return &load_template ('link_related.html',
{ detailed_url => "$db_detailed_url/$rel{'ID'}$build_extension",
title => $title,
%rel,
%globals

});}

3.) Added template link_related.html:
<ul><li><a href="<%URL%>"><%Title%></a></li></ul>


4.) In nph-build.cgi:


sub build_detailed_view {
# --------------------------------------------------------
# This routine build a single page for every link.
#
my (@values, $id, %rec, $count);
if ($build_detail_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
print "\t";

open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;

@values = &split_decode ($_);
$id = $values[$db_key_pos];
%rec = &array_to_hash (0, @values);

$title_linked = &build_linked_title ("$rec{'Category'}/$rec{'Title'}");

$relatedlink = "";
@rel = split(/~/, $rec{'Relatedlink'});
foreach $related_link (@rel) {
my (%rel) = &get_record ($related_link);
$relatedlink .= &site_html_related_link (%rel);
}

open (DETAIL, ">$build_detail_path/$id$build_extension") or &cgierr ("Unable to build detail page: $build_detail_path/$id$build_extension. Reason: $!");
print DETAIL &site_html_detailed (%rec, $relatedlink);
close DETAIL;
$use_html ?
print qq~<a href="$build_detail_url/$id$build_extension" target="_blank">$id</a> ~ :
print qq~$id ~;
(++$count % 10) or print "\n\t";
}
close DB;
print "\n";
}




The mod stops working completely (as opposed to on the first detailed page with related links) when I add $relatedlink to

my (@values, $id, %rec, $count);

Quote Reply
Re: Related Links MOD In reply to
just moving up the post :)

Quote Reply
Re: Related Links MOD In reply to
In Reply To:
just moving up the post :)
Why? [arggggghhhh]

Quote Reply
Re: Related Links MOD In reply to
I spent a long time on this trying to get it work- I was just looking for some help.