--- loncom/interface/lonhtmlcommon.pm 2025/03/06 16:51:36 1.421
+++ loncom/interface/lonhtmlcommon.pm 2025/03/25 01:02:59 1.422
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.421 2025/03/06 16:51:36 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.422 2025/03/25 01:02:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3964,6 +3964,8 @@ sub list_from_array {
# Inputs:
# An array of following structure:
# ({ categorytitle => 'Categorytitle',
+# listclass=>'class to use for
tag for listed items in category (optional)
+# boxclass=>'a class to use for the div which provides the box for the category (optional),
# items => [
# {
# linktext => 'Text to be displayed',
@@ -3981,13 +3983,15 @@ sub list_from_array {
# ...
# )
#
+# if listclass is not provided, LC_ListStyleNormal will be used.
+# if box class is not provided, LC_Box will be used.
# Outputs: A scalar containing the html markup for the menu.
sub generate_menu {
my @menu = @_;
# subs for specific html elements
- my ($h2, $div, $ul, $li, $a, $img) = inittags( qw(h2 div ul li a img) );
-
+ my ($h2, $div, $ul, $li, $a, $img, $span) = inittags( qw(h2 div ul li a img span) );
+
my @categories; # each element represents the entire markup for a category
foreach my $category (@menu) {
@@ -4009,7 +4013,8 @@ sub generate_menu {
src => $src,
alt => mt(defined($$link{alttext}) ?
$$link{alttext} : $$link{linktext})
- }).mt($$link{linktext}), {
+ }).$span->(mt($$link{linktext}), {
+ class => "LC_menu_text",}), {
href => $$link{url},
title => mt($$link{linktitle}),
class => "LC_menubuttons_link"
@@ -4018,6 +4023,14 @@ sub generate_menu {
Apache::loncommon::help_open_topic($$link{help}) : ''),
{class => "LC_menubuttons_inline_text"}));
}
+ my $ulclass = 'LC_ListStyleNormal';
+ if ($category->{'listclass'} ne '') {
+ $ulclass = $category->{'listclass'};
+ }
+ my $boxclass = 'LC_Box';
+ if ($category->{'boxclass'} ne '') {
+ $boxclass = $category->{'boxclass'};
+ }
# wrap categorytitle in , concatenate with
# joined and in tags wrapped @links
@@ -4028,8 +4041,8 @@ sub generate_menu {
# the category won't be added if there aren't any links
push(@categories,
$div->($h2->(mt($$category{categorytitle}), {class=>'LC_hcell LC_heading_2'}).
- $ul->(join('' ,@links), {class =>"LC_ListStyleNormal" }),
- {class=>"LC_Box LC_400Box"})) if scalar(@links);
+ $ul->(join('' ,@links), {class =>"$ulclass" }),
+ {class=>"$boxclass LC_400Box"})) if scalar(@links);
}
# wrap the joined @categories in another (column layout)