Has anyone created a mod to make a navigation menu out of the categories and sub categories that could be displayed on the home and category template?
So far I have added this sub to db_util.pl.
This is a sub just like build_select_field with changes to the $output var.
foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<option value="$build_root_url/$field/index.html">$field</option\n") ;
sub build_nav_menu {
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $mult) = @_;
my ($size, %values);
$name || ($name = $column);
$size || ($size = 1);
# commented out 11/20/2003
#$db_select_fields{'Mult-Subcats'} = join (",", &category_list);
if (! exists $db_select_fields{$column}) {
$db_select_fields{$db_cols[$db_category]} = $db_select_fields{'Mult-Related'} = join (",", &category_list);
# code added for multiple cat mod to show on add - mod forms
if (! exists $db_select_fields{$column} && $column eq "AltCategories" && exists $db_select_fields{'Category'}) { $db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = $db_select_fields{'Category'}} elsif (! exists $db_select_fields{$column} && $column eq "AltCategories" && ! exists $db_select_fields{'Category'}) { $db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = join (",", &category_list);}
# end of multiple cat mod
}
if ($mult) {
@fields = split (/\,/, $db_select_fields{"Mult-$column"});
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
@fields = split (/\,/, $db_select_fields{$column});
$values{$value}++;
}
($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";
$output = qq|<SELECT NAME="$name" $mult SIZE=$size><OPTION>---|;
foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<option value="$build_root_url/$field/index.html">$field</option\n") ;
}
$output .= "</SELECT>";
return $output;
}
I also made this modification to site_html_templates.pl but commented it out because it didn't work. Tried it in Golbals instead. Didn't work.
# --------------Sub to build the home page-------------------
sub site_html_home {
#tried this here but didn't work, then put nav_menu in globals
#my $nav_menu = &build_nav_menu ("Category", "$in{'Category'}");
return &load_template ('index.html', {
category => $category,
nav_menu => $nav_menu
grand_total => $grand_total,
%globals
});
}
Added to Globals:
nav_menu => $build_nav_menu
When you click build you get a download prompt warning about harmful files, reference: nph-build.cgi.
Can anyone help?
Yes permissions are set correctly.
Thanks
Jake
So far I have added this sub to db_util.pl.
This is a sub just like build_select_field with changes to the $output var.
foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<option value="$build_root_url/$field/index.html">$field</option\n") ;
sub build_nav_menu {
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition.
#
my ($column, $value, $name, $mult) = @_;
my ($size, %values);
$name || ($name = $column);
$size || ($size = 1);
# commented out 11/20/2003
#$db_select_fields{'Mult-Subcats'} = join (",", &category_list);
if (! exists $db_select_fields{$column}) {
$db_select_fields{$db_cols[$db_category]} = $db_select_fields{'Mult-Related'} = join (",", &category_list);
# code added for multiple cat mod to show on add - mod forms
if (! exists $db_select_fields{$column} && $column eq "AltCategories" && exists $db_select_fields{'Category'}) { $db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = $db_select_fields{'Category'}} elsif (! exists $db_select_fields{$column} && $column eq "AltCategories" && ! exists $db_select_fields{'Category'}) { $db_select_fields{$db_cols[$db_alt_cat]} = $db_select_fields{'Mult-AltCategories'} = join (",", &category_list);}
# end of multiple cat mod
}
if ($mult) {
@fields = split (/\,/, $db_select_fields{"Mult-$column"});
%values = map { $_ => 1 } split (/\Q$db_delim\E/, $value);
}
else {
@fields = split (/\,/, $db_select_fields{$column});
$values{$value}++;
}
($#fields >= 0) or return "error building select field: no select fields specified in config for field '$column'!";
$output = qq|<SELECT NAME="$name" $mult SIZE=$size><OPTION>---|;
foreach $field (@fields) {
$values{$field} ?
($output .= "<OPTION SELECTED>$field\n") :
($output .= "<option value="$build_root_url/$field/index.html">$field</option\n") ;
}
$output .= "</SELECT>";
return $output;
}
I also made this modification to site_html_templates.pl but commented it out because it didn't work. Tried it in Golbals instead. Didn't work.
# --------------Sub to build the home page-------------------
sub site_html_home {
#tried this here but didn't work, then put nav_menu in globals
#my $nav_menu = &build_nav_menu ("Category", "$in{'Category'}");
return &load_template ('index.html', {
category => $category,
nav_menu => $nav_menu
grand_total => $grand_total,
%globals
});
}
Added to Globals:
nav_menu => $build_nav_menu
When you click build you get a download prompt warning about harmful files, reference: nph-build.cgi.
Can anyone help?
Yes permissions are set correctly.
Thanks
Jake