From 6f20b8c727692e84b2a8da8e71ade11146d0e36b Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Thu, 1 Mar 2018 15:34:02 -0500 Subject: [PATCH] LP#1752434: Use display fields even when not highlighting 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 Signed-off-by: Remington Steed Signed-off-by: Galen Charlton --- Open-ILS/src/templates/opac/parts/misc_util.tt2 | 43 ++++++++++++---------- .../src/templates/opac/parts/record/series.tt2 | 3 +- .../src/templates/opac/parts/record/subjects.tt2 | 4 +- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2 index e4bf98c8ba..6f3d18bf8c 100644 --- a/Open-ILS/src/templates/opac/parts/misc_util.tt2 +++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2 @@ -108,28 +108,33 @@ 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 = {}; diff --git a/Open-ILS/src/templates/opac/parts/record/series.tt2 b/Open-ILS/src/templates/opac/parts/record/series.tt2 index 4c42baf142..a5ad664c8b 100644 --- a/Open-ILS/src/templates/opac/parts/record/series.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/series.tt2 @@ -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 = '' _ s.highlight _ ' '; + series = '' _ s.$hl_field _ ' '; results.push(series); END; ELSE; diff --git a/Open-ILS/src/templates/opac/parts/record/subjects.tt2 b/Open-ILS/src/templates/opac/parts/record/subjects.tt2 index 73ae64f482..f987125c38 100644 --- a/Open-ILS/src/templates/opac/parts/record/subjects.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/subjects.tt2 @@ -91,7 +91,7 @@ ''; %][% s.highlight %] [%- + -%]">[% s.$f %] [%- ''; END; %] @@ -104,7 +104,7 @@ 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; -- 2.11.0