LP#1744385: Use series_title highlighting in OPAC
authorMike Rylander <mrylander@gmail.com>
Fri, 16 Feb 2018 17:27:24 +0000 (12:27 -0500)
committerDan Wells <dbw2@calvin.edu>
Wed, 28 Feb 2018 21:19:04 +0000 (16:19 -0500)
Here we replace the series title link generation based directly on the MARCXML
with the Display Field equivalent.  Note, the previous method created broken
links in many cases, because it included more in the search terms than were
being indexed by the stock series title definition.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Starting # ../../../../multi-source-attrs.sql

Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/templates/opac/parts/record/series.tt2

index 4be6b83..4c42baf 100644 (file)
@@ -4,37 +4,49 @@
 
 BLOCK render_series;
     results = [];
-    FOR tag IN series_tags;
-        FOR node IN ctx.marc_xml.findnodes('//*[@tag="' _ tag _ '"]');
-            all_terms = [];
-            graphics = [];
-            series = '';
-            FOR subfield IN node.childNodes;
-                NEXT UNLESS subfield.nodeName == "subfield";
-                code = subfield.getAttribute('code');
-                IF code == '6';
-                   linked_fields = [subfield.textContent()];
-                   target_field = node.getAttribute('tag');
-                   get_linked_880s;
-                END;
-                NEXT UNLESS code.match('[a-z]');
-                # at this point, we actually have a partial term to use.
-                single_term = subfield.textContent | html;
-                all_terms.push(subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ' '));
-                total_term = all_terms.join(" ").replace('\s+$', '');
-
-                url = mkurl(ctx.opac_root _ '/results',
-                    { qtype=>'series', query=>total_term }, stop_parms.merge(expert_search_parms, general_search_parms, browse_search_parms, facet_search_parms)
-                );
-                series = series _ '<a href="' _ url _ '">' _ single_term _ '</a> ';
-            END;
-            FOREACH link880 IN graphics;
-                link = link880.value | html;
-                series = series _ '<div class="graphic880"' _ link880.dir _ '>' _ link _ '</div>';
-            END;
+    IF attrs.hl_display_fields.series_title.size;
+        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> ';
             results.push(series);
         END;
-    END; 
+    ELSE;
+        FOR tag IN series_tags;
+            FOR node IN ctx.marc_xml.findnodes('//*[@tag="' _ tag _ '"]');
+                all_terms = [];
+                graphics = [];
+                series = '';
+                FOR subfield IN node.childNodes;
+                    NEXT UNLESS subfield.nodeName == "subfield";
+                    code = subfield.getAttribute('code');
+                    IF code == '6';
+                       linked_fields = [subfield.textContent()];
+                       target_field = node.getAttribute('tag');
+                       get_linked_880s;
+                    END;
+                    NEXT UNLESS code.match('[a-z]');
+                    # at this point, we actually have a partial term to use.
+                    single_term = subfield.textContent | html;
+                    all_terms.push(subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ' '));
+                    total_term = all_terms.join(" ").replace('\s+$', '');
+    
+                    url = mkurl(ctx.opac_root _ '/results',
+                        { qtype=>'series', query=>total_term }, stop_parms.merge(expert_search_parms, general_search_parms, browse_search_parms, facet_search_parms)
+                    );
+                    series = series _ '<a href="' _ url _ '">' _ single_term _ '</a> ';
+                END;
+                FOREACH link880 IN graphics;
+                    link = link880.value | html;
+                    series = series _ '<div class="graphic880"' _ link880.dir _ '>' _ link _ '</div>';
+                END;
+                results.push(series);
+            END;
+        END; 
+    END;
     FOR entry IN results;
     -%]
     <li class='rdetail_series_value'>[% entry %]</li>