Well, here is a possible solution:
1) Add the following sub-routine in your
db_utils.pl file:
Code:
sub load_search_templates {
#-------------------------------------------
# Loads and parses a template. Expects to find as input a
# template file name, and a hash ref and optionally template text.
# If text is defined, then no file is loaded, but rather the template
# is taken from $text.
#
my ($tpl, $vars, $string) = @_;
(ref $vars eq 'HASH') or &cgierr ("Not a hash ref: $vars in load_template!")
;
if (!defined $db_template) {
require "$db_lib_path/Template.pm";
$db_template = new Template ( { ROOT => $db_template_search_path, CHECK => 0 }
);
}
$db_template->clear_vars;
$db_template->load_template ($tpl, $string) or &cgierr ("Can't load template
. Reason: $Template::error");
$db_template->load_vars ($vars) or &cgierr ("Can't load variable
s. Reason: $Template::error");
return $db_template->parse ($tpl) or &cgierr ("Can't parse templat
e. Reason: $Template::error");
}
2) Add the following variable in the
links.cfg file:
Code:
$db_template_search_path = "$db_script_path/searchtemplates";
3) Create a directory called
searchtemplates.
4) Then in your
site_html_template.pl file, change the following sub-routine calls in ALL the search template sub-routines:
to the following:
Code:
&load_search_templates
5) Then upload the various template files in this directory.
6) Then in your
admin_html.pl template file, add the following codes:
Code:
sub html_edit_search_template {
# --------------------------------------------------------
# Lets the user edit his templates.
#
my $message = shift;
my $templates = &get_template_list($in{'edit_tpl'});
my $text = '';
if ($in{'edit_tpl'} =~ /^[\w\d_\-]+\.[\w\d_\-]+$/) {
open (TPL, "<$db_template_search_path/$in{'edit_tpl'}") or &cgierr ("Can't load template: $db_template_path/$in{'edit_tpl'}. Reason: $!");
$text = join "", <TPL>;
close TPL;
$text =~ s,</textarea>,</text-area>,ig;
}
my $save_as = $in{'edit_tpl'};
&html_print_headers();
print qq|
<html>
<head>
<title>$html_title: Edit Templates.</title>
</head>
<body bgcolor="#FFFFFF">
<form action="$db_script_url" METHOD="POST">
<input type=hidden name="db" value="$in{'db'}">
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Edit Templates</b>
</td></tr>
</table>
<p><$font color=red><b>$message</b></font></p>
|; if ($in{'edit_tpl'}) { print qq~<p><$font><b><a href="$db_script_url&html_template_help=1&template=$in{'edit_tpl'}">Template Help and Codes you can use!</a></b></font></p>~; } print qq|
<p><$font>Available Search Templates: $templates <input type=submit name="html_edit_search_template" value="Edit!">
<p><textarea name=tpl rows=40 cols=60>$text</textarea>
<p><$font>Save as: <input name="save_tpl" value="$save_as"></font>
<p><INPUT TYPE="SUBMIT" NAME="save_search_template" VALUE="Save Template"> <INPUT TYPE="RESET" VALUE="Reset Form"></p>
</body>
</html>
|;
}
That should do it...Let me know if I missed something or if you get error messages.
The next tricky step will do that template argument in the
search.cgi script.
But I would prefer you make these changes before we proceed.
Hope this helps.
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!!
----------------------