Hi,
I was asked by someone to write a small mod for a charity website. It basically lets you use:
<%prev%>
<%next%>
...on detailed.html.
It will only link to the "next" and "previous" links inside the same category.
The hack is pretty simple (well, wasn't that simple to write, but its easy to install <G>)
1) Open up /admin/site_html_templates.pl , and below:
# THE FOLLOWING ARE CGI GENERATED PAGES AND THE TEMPLATE MUST BE PRINTED, NOT RETURNED!#
########################################################################################
..add:
my $category = $_[0];
my $linkid = $_[1];
my ($use,$id);
open (READIT,"$db_script_path/data/links.db") || die "Cant read: $db_script_path/data/links.db . Reason: $!";
while (<READIT>) {
# 0: id | 1: title | 2: url | 3: add date | 4: category | 5: desc
chomp;
my @tmp = split /\|/, $_;
if ($tmp[4] ne $category) { next; } # skip anything that isn't in this category.
if ($tmp[0] < $linkid && $id ne $linkid) {
$use = $build_detail_url . "/" . $tmp[0] . $build_extension;
$id = $tmp[0];
}
}
close (READIT);
if (!$use) { return "" } else { return qq|<a href="$use">PREV LINK</a>|; }
}
sub make_next_link {
my $category = $_[0];
my $linkid = $_[1];
my ($use,$id);
open (READIT,"$db_script_path/data/links.db") || die "Cant read: $db_script_path/data/links.db . Reason: $!";
while (<READIT>) {
# 0: id | 1: title | 2: url | 3: add date | 4: category | 5: desc
chomp;
my @tmp = split /\|/, $_;
if ($tmp[4] ne $category) { next; } # skip anything that isn't in this category.
if ($tmp[0] > $linkid && $id ne $linkid) {
$use = $build_detail_url . "/" . $tmp[0] . $build_extension;
$id = $tmp[0];
last;
}
}
close (READIT);
if (!$use) { return "" } else { return qq|<a href="$use">NEXT LINK</a>|; }
}
Then, find:
# --------------------------------------------------------
# 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', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
%rec,
%globals
} );
}
..and change it to:
# --------------------------------------------------------
# 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 = @_;
my $next = make_next_link($rec{'Category'},$rec{'ID'});
my $prev = make_prev_link($rec{'Category'},$rec{'ID'});
return &load_template ('detailed.html', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
next => $next,
prev => $prev,
%rec,
%globals
} );
}
Then, just edit detailed.html, so you have:
<%prev%> and <%next%> whereever you want it to show.
NB: If, for example on the <%next%> link there is no ID that exists in the same category, with a higher ID - then it will just return a blank - i.e no link. This isn't a bug
Enjoy!
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
I was asked by someone to write a small mod for a charity website. It basically lets you use:
<%prev%>
<%next%>
...on detailed.html.
It will only link to the "next" and "previous" links inside the same category.
The hack is pretty simple (well, wasn't that simple to write, but its easy to install <G>)
1) Open up /admin/site_html_templates.pl , and below:
Code:
######################################################################################## # THE FOLLOWING ARE CGI GENERATED PAGES AND THE TEMPLATE MUST BE PRINTED, NOT RETURNED!#
########################################################################################
..add:
Code:
sub make_prev_link { my $category = $_[0];
my $linkid = $_[1];
my ($use,$id);
open (READIT,"$db_script_path/data/links.db") || die "Cant read: $db_script_path/data/links.db . Reason: $!";
while (<READIT>) {
# 0: id | 1: title | 2: url | 3: add date | 4: category | 5: desc
chomp;
my @tmp = split /\|/, $_;
if ($tmp[4] ne $category) { next; } # skip anything that isn't in this category.
if ($tmp[0] < $linkid && $id ne $linkid) {
$use = $build_detail_url . "/" . $tmp[0] . $build_extension;
$id = $tmp[0];
}
}
close (READIT);
if (!$use) { return "" } else { return qq|<a href="$use">PREV LINK</a>|; }
}
sub make_next_link {
my $category = $_[0];
my $linkid = $_[1];
my ($use,$id);
open (READIT,"$db_script_path/data/links.db") || die "Cant read: $db_script_path/data/links.db . Reason: $!";
while (<READIT>) {
# 0: id | 1: title | 2: url | 3: add date | 4: category | 5: desc
chomp;
my @tmp = split /\|/, $_;
if ($tmp[4] ne $category) { next; } # skip anything that isn't in this category.
if ($tmp[0] > $linkid && $id ne $linkid) {
$use = $build_detail_url . "/" . $tmp[0] . $build_extension;
$id = $tmp[0];
last;
}
}
close (READIT);
if (!$use) { return "" } else { return qq|<a href="$use">NEXT LINK</a>|; }
}
Then, find:
Code:
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', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
%rec,
%globals
} );
}
..and change it to:
Code:
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 = @_;
my $next = make_next_link($rec{'Category'},$rec{'ID'});
my $prev = make_prev_link($rec{'Category'},$rec{'ID'});
return &load_template ('detailed.html', {
total => $total,
grand_total => $grand_total,
title_linked => $title_linked,
next => $next,
prev => $prev,
%rec,
%globals
} );
}
Then, just edit detailed.html, so you have:
<%prev%> and <%next%> whereever you want it to show.
NB: If, for example on the <%next%> link there is no ID that exists in the same category, with a higher ID - then it will just return a blank - i.e no link. This isn't a bug
Enjoy!
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

