LP#1752434: Use display fields even when not highlighting
authorMike Rylander <mrylander@gmail.com>
Thu, 1 Mar 2018 20:34:02 +0000 (15:34 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 30 Apr 2018 18:44:34 +0000 (14:44 -0400)
Always retrieve display field data, and decide whether to use the highlighted
version of each based on the configuration and user option rather than falling
back to template-side MARC extraction when not highlighting.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Remington Steed <rjs7@calvin.edu>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/record/series.tt2
Open-ILS/src/templates/opac/parts/record/subjects.tt2

index e4bf98c..6f3d18b 100644 (file)
 
         args.display_fields = {};
         args.hl = {};
-        IF !CGI.param('no_highlight') && !search.no_highlight;
-
-            args.display_field_list = ctx.fetch_display_fields(args.df_bib_list.list);
-
-            junk = ctx.timelog('Mapping highlighted display fields for bib(s) ' _ args.df_bib_list.list.join(', ')); 
-            FOR df IN args.display_field_list;
-                df_map = ctx.search_cdfm('field', df.field).0;
-                df_name = df_map.name();
-                IF df_map.multi() == 't';
-                    IF NOT args.hl_display_fields.$df_name;
-                        args.hl_display_fields.$df_name = [];
-                        args.hl.$df_name = [];
-                    END;
-                    args.hl_display_fields.$df_name.push(df);
-                    args.hl.$df_name.push(df.highlight || df.value);
-                ELSIF !args.hl_display_fields.$df_name.defined;
-                    args.hl_display_fields.$df_name = df;
-                    args.hl.$df_name = df.highlight || df.value;
+
+        args.hl_field = 'highlight';
+        IF CGI.param('no_highlight') || search.no_highlight;
+            args.hl_field = 'value';
+        END;
+        hl_field = args.hl_field;
+
+        junk = ctx.timelog('Fetching display fields and Using data from "' _ hl_field _ '" for rendering'); 
+        args.display_field_list = ctx.fetch_display_fields(args.df_bib_list.list);
+
+        junk = ctx.timelog('Mapping display fields for bib(s) ' _ args.df_bib_list.list.join(', ')); 
+        FOR df IN args.display_field_list;
+            df_map = ctx.search_cdfm('field', df.field).0;
+            df_name = df_map.name();
+            IF df_map.multi() == 't';
+                IF NOT args.hl_display_fields.$df_name;
+                    args.hl_display_fields.$df_name = [];
+                    args.hl.$df_name = [];
                 END;
+                args.hl_display_fields.$df_name.push(df);
+                args.hl.$df_name.push(df.$hl_field || df.value);
+            ELSIF !args.hl_display_fields.$df_name.defined;
+                args.hl_display_fields.$df_name = df;
+                args.hl.$df_name = df.$hl_field || df.value;
             END;
-            junk = ctx.timelog('Finished mapping highlighted display fields for bib(s) ' _ args.df_bib_list.list.join(', ')); 
         END;
+        junk = ctx.timelog('Finished mapping display fields for bib(s) ' _ args.df_bib_list.list.join(', ')); 
 
         # Map item types to schema.org types; impedance mismatch :(
         args.schema.itemtype = {};
index 4c42baf..a5ad664 100644 (file)
@@ -5,13 +5,14 @@
 BLOCK render_series;
     results = [];
     IF attrs.hl_display_fields.series_title.size;
+        hl_field = attrs.hl_field;
         FOREACH s IN attrs.hl_display_fields.series_title;
             search_term = s.value.replace('[#"^$\+\-,\.:;&|\[\]()]', ' ').replace('\s+$', '') | html;
     
             url = mkurl(ctx.opac_root _ '/results',
                 { qtype=>'series', query=>search_term }, stop_parms.merge(expert_search_parms, general_search_parms, browse_search_parms, facet_search_parms)
             );
-            series = '<a href="' _ url _ '">' _ s.highlight _ '</a> ';
+            series = '<a href="' _ url _ '">' _ s.$hl_field _ '</a> ';
             results.push(series);
         END;
     ELSE;
index 73ae64f..f987125 100644 (file)
@@ -91,7 +91,7 @@
         '<span property="about"><!-- highlighted -->';
         %]<a href="[%-
                mkurl(ctx.opac_root _ '/results', {qtype=>'subject', query=>total_term}, stop_parms.merge(expert_search_parms, general_search_parms, browse_search_parms, facet_search_parms))
-        -%]">[% s.highlight %]</a> [%-
+        -%]">[% s.$f %]</a> [%-
         '</span>';
     END;
 %]
             content = [];
             FOREACH hl_s IN attrs.hl_display_fields.$df;
                 hl_s.facet = subj.facet;
-                next_s = PROCESS render_hl_subject(s=hl_s);
+                next_s = PROCESS render_hl_subject(s=hl_s,f=attrs.hl_field);
                 content.push(next_s);
             END;