Allow multiple icon styles user/tsbere/multiple_icon_styles
authorThomas Berezansky <tsbere@mvlc.org>
Fri, 23 Oct 2015 15:20:02 +0000 (11:20 -0400)
committerThomas Berezansky <tsbere@mvlc.org>
Fri, 23 Oct 2015 15:20:02 +0000 (11:20 -0400)
Comma-delimited list, First one with icons wins.

icon_format,item_type would be "new style, then old style".

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Open-ILS/src/templates/opac/parts/misc_util.tt2

index 6c2cb47..8166685 100644 (file)
         END;
 
         # "mattype" == "custom marc format specifier"
-        icon_style = ctx.get_cgf('opac.icon_attr').value || 'item_type';
-        formats_xpath = '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]';
-
-        args.all_formats = [];
-        FOR node IN xml.findnodes(formats_xpath);
-            IF node AND node.textContent;
-                ccvm = ctx.get_ccvm(node.getAttribute('cvmid'));
-                NEXT IF ccvm.opac_visible == 'f';
-
-                format = {};
-                type = ccvm.code.remove('-'); # blu-ray to bluray
-                format.label = ccvm.search_label || ccvm.value;
-                format.icon = PROCESS get_ccvm_icon ccvm=ccvm;
-                format.itemtype = schema_typemap.$type || 'CreativeWork';
-
-                args.all_formats.push(format); # metarecords want all formats
-
-                IF !args.format_label;
-                    # use the first format as the default
-                    args.format_label = format.label; 
-                    args.schema.itemtype = format.itemtype;
-                    args.format_icon = format.icon;
+        icon_styles = ctx.get_cgf('opac.icon_attr').value || 'item_type';
+        FOREACH icon_style IN icon_styles.split(',');
+            formats_xpath = '//*[local-name()="attributes"]/*[local-name()="field"][@name="' _ icon_style _ '"]';
+
+            args.all_formats = [];
+            FOR node IN xml.findnodes(formats_xpath);
+                IF node AND node.textContent;
+                    ccvm = ctx.get_ccvm(node.getAttribute('cvmid'));
+                    NEXT IF ccvm.opac_visible == 'f';
+
+                    format = {};
+                    type = ccvm.code.remove('-'); # blu-ray to bluray
+                    format.label = ccvm.search_label || ccvm.value;
+                    format.icon = PROCESS get_ccvm_icon ccvm=ccvm;
+                    format.itemtype = schema_typemap.$type || 'CreativeWork';
+
+                    args.all_formats.push(format); # metarecords want all formats
+
+                    IF !args.format_label;
+                        # use the first format as the default
+                        args.format_label = format.label; 
+                        args.schema.itemtype = format.itemtype;
+                        args.format_icon = format.icon;
+                    END;
                 END;
             END;
+            LAST IF args.all_formats.size > 0;
         END;
        
         args.bibid = [];