i guess i should give you guys more instructions?
FIRST.. go through HTML_Templates.pm and change all the "$template" scalars to "$style".. if you haven't already..
Also.. Add this below the %GLOBALS at the top
Code:
my $TEMPLATES = $LINKS{admin_root_path}/templates";
i used that for a reason that you guys might now really need.. it has to do with page.cgi.. but yea..
ok.. these are mostly in nph-build.cgi
in the my list at top add:
Code:
, $get_ctemp, $get_ltemp
in sub build_category_pages, under:
Code:
$OUT{random3} = rand{10000};
put:
Code:
$get_ctemp = $CATDB->prepare ("SELECT Template FROM Category WHERE Name = ?");
$get_ltemp = $CATDB->prepare ("SELECT Link_Template FROM Category WHERE Name = ?");
# Get the template information.
$OUT{category_root} = $category_r->{'Name'};
while (!$category_r->{'Template'} && !$category_r->{'Link_Template'}) {
$OUT{category_root} =~ s,/[^/]+$,,;
if (!$category_r->{'Template'}) {
$get_ctemp->execute($OUT{category_root});
$category_r->{'Template'} = $get_ctemp->fetchrow_array;
}
if (!$category_r->{'Link_Template'}) {
$get_ltemp->execute($OUT{category_root});
$category_r->{'Link_Template'} = $get_ltemp->fetchrow_array;
}
last if ($OUT{category_root} =~ m,^[^/]+$,);
}
$category_r->{'Template'}
||= "category.html";
$category_r->{'Link_Template'}
||= "link.html";
then in sub build_detailed_view..
in the my list.. add:
under:
Code:
$category = $CATDB->get_record ($link->{'CategoryID'}, 'HASH');
add
Code:
$get_temp = $CATDB->prepare ("SELECT Detail_Template FROM Category WHERE Name = ?");
# Get template information.
$OUT{category_root} = $category->{'Name'};
while (!$link->{'Detail_Template'}
|| !$category->{'Detail_Template'}) {
$OUT{category_root} =~ s,/[^/]+$,,;
$get_temp->execute($OUT{category_root});
$category->{'Detail_Template'} = $get_temp->fetchrow_array;
last if ($OUT{category_root} =~ m,^[^/]+$,);
}
$category->{'Detail_Template'}
||= "detailed.html";
those are the loops that get the templates from previous categories..
then replace:
Code:
print DETAIL &site_html_detailed ($link, { grand_total => $GRAND_TOTAL, title_linked => $title_linked });
with:
Code:
print DETAIL &site_html_detailed ($link, { grand_total => $GRAND_TOTAL, title_linked => $title_linked }, $category->{'Detail_Template'});
this is probably the worst coding i've ever done
i'm sure if i put something like this into build_stats and save the templates onto memory.. it will look better.. however.. i am avoiding build_stats on all my mods in order for it to not crash for the really big databases..
ok.. there are a few more things.. let's start with HTML_Templates.pm again..
in sub site_html_link...
Code:
my ($rec, $dynamic) = @_;
change to:
Code:
my ($rec, $template, $dynamic) = @_;
under:
Code:
($rec->{'isPopular'} eq 'Yes') ? ($rec->{'isPopular'} = 1) : (delete $rec->{'isPopular'});
add:
Code:
$rec->{'Template'}
||= $template;
(-e "$TEMPLATES/${$rec}{'Template'}" && $rec->{'Template'}) or ($rec->{'Template'} = "link.html");
replace:
Code:
my $output = &load_template ('link.html', {
with:
Code:
my $output = &load_template ($rec->{'Template'}, {
go through all the blah blah blah &site_html_link blah blah blah.. in build_category_pages in nph-build.cgi
there are three.. they look like this..
Code:
$OUT{links} .= &site_html_link ($tmp);
replace with:
Code:
$OUT{links} .= &site_html_link ($tmp, $category_r->{'Link_Template'});
ok.. now you've got a problem.. page.cgi
first go to generate_category_page
add to the my list at top..
Code:
, $get_ctemp, $get_ltemp
under:
Code:
$OUT{random3} = rand (10000);
add:
Code:
$get_ctemp = $CATDB->prepare ("SELECT Template FROM Category WHERE Name = ?");
$get_ltemp = $CATDB->prepare ("SELECT Link_Template FROM Category WHERE Name = ?");
$OUT{category_root} = $category_r->{'Name'};
while (!$category_r->{'Template'} && !$category_r->{'Link_Template'}) {
$OUT{category_root} =~ s,/[^/]+$,,;
if (!$category_r->{'Template'}) {
$get_ctemp->execute($OUT{category_root});
$category_r->{'Template'} = $get_ctemp->fetchrow_array;
}
if (!$category_r->{'Link_Template'}) {
$get_ltemp->execute($OUT{category_root});
$category_r->{'Link_Template'} = $get_ltemp->fetchrow_array;
}
last if ($OUT{category_root} =~ m,^[^/]+$,);
}
$category_r->{'Template'}
||= "category.html";
$category_r->{'Link_Template'}
||= "link.html";
change:
Code:
$OUT{links} .= &site_html_link ($tmp, $in);
to:
Code:
$OUT{links} .= &site_html_link ($tmp, $category_r->{'Link_Template'}, $in);
ok.. now the REST of the site_html_link(blah, blah)s need to be changed..
go through the entire page.cgi and replace all the
Code:
&site_html_link (
$link, $in);
with:
Code:
&site_html_link (
$link, undef, $in);
sometimes the $link is not $link..
go to generate_detailed_page..
add this to the mylist on top..
under:
Code:
$category = $cat_db->get_record ($link->{'CategoryID'}, 'HASH');
add:
Code:
# Get template information.
$OUT{category_root} = $category->{'Name'};
while (!$link->{'Detail_Template'}
|| !$category->{'Detail_Template'}) {
$OUT{category_root} =~ s,/[^/]+$,,;
$get_temp->execute($OUT{category_root});
$category->{'Detail_Template'} = $get_temp->fetchrow_array;
last if ($OUT{category_root} =~ m,^[^/]+$,);
}
$category->{'Detail_Template'}
||= "detailed.html";
ugh..
replace:
Code:
print &site_html_detailed ($link, { grand_total => $GRAND_TOTAL, title_linked => $title_linked }, $in);
with
Code:
print &site_html_detailed ($link, { grand_total => $GRAND_TOTAL, title_linked => $title_linked }, $category->{'Detail_Template'}, $in);
OK... then in HTML_Templates.pm again..
sub site_html_detailed
Code:
my ($rec, $tags, $dynamic) = @_;
to
Code:
my ($rec, $tags, $template, $dynamic) = @_;
under:
Code:
($rec->{'isPopular'} eq 'Yes') ? ($rec->{'isPopular'} = 1) : (delete $rec->{'isPopular'});
add:
Code:
$rec->{'Detail_Template'}
||= $template;
(-e "$TEMPLATES/${$rec}{'Detail_Template'}" && $rec->{'Detail_Template'}) or ($rec->{'Detail_Template'} = "detailed.html");
replace:
Code:
my $output = &load_template ('detailed.html', {
with
Code:
my $output = &load_template ($rec->{'Detail_Template'}, {
now.. go to site_html_category..
replace
Code:
my ($tags, $dynamic) = @_;
with
Code:
my ($tags, $template, $dynamic) = @_;
then under:
Code:
my ($name) = $tags->{'category_name'} =~ m,/?([^/]+)$,;
add:
Code:
(-e "$TEMPLATES/$template" && $template) or ($template = "category.html");
ahh....
then replace..
Code:
my $output = &load_template ('category.html', {
with:
Code:
my $output = &load_template ($template, {
i think we're done... that's ALOT of typing..
jerry
[This message has been edited by widgetz (edited January 12, 2000).]