LP#1037171 Removed Expert Search paramters from subject links
authorLiam Whalen <whalen.ld@gmail.com>
Mon, 7 Oct 2013 05:11:56 +0000 (22:11 -0700)
committerMike Rylander <mrylander@gmail.com>
Wed, 20 Nov 2013 15:35:26 +0000 (10:35 -0500)
After performing an Expert Search, if a user visits a record and then
clicks on one of the author, subject, or series search links within
that record, then they are given the results of the Expert Search again
instead of the relevant subject or author search.

This is happening because the Expert Search parameters are retained in
the URLs via the TT2 MACRO mkurl.  In particular, the tag parameter is
used to identify an Expert Search, so if it is present in a URL, than an
Expert Search will be attempted regardless of which other paramaters are
in the URL.

To fix this, I created two varialbes within header.tt2 above the
definition of mkurl.  These variables group common URL paramters for
Expert Searches and General Search parameters together.  These variables
can be used wherever mkurl is used to strip out unneeded search
paramters.

There is a third variable that is already present within many of these
pages named stop_parms.  While I initially tried to modify this
variable, I found that there are some instances where the general search
parameters should be retained while the Expert Search parameters must go.

This commit uses these three variables togehter as input into the third
arugment of the mkurl MACRO.  The third arugment specifies which
paramtes to remove from the previous URL before making a new URL based
on the pervious URL.

I also added the query parameter to the Place Hold's hold_source_page
URL variable.  I did this, so that the query terms would be preserved
once the user is done placing the hold or decides to cancle the placing
of the hold.

As well, I used the new variables to remove Expert Search paramters
from the Advanced Search links on the results and record pages.

Signed-off-by: Liam Whalen <whalen.ld@gmail.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/opac/parts/header.tt2
Open-ILS/src/templates/opac/parts/record/authors.tt2
Open-ILS/src/templates/opac/parts/record/series.tt2
Open-ILS/src/templates/opac/parts/record/subjects.tt2
Open-ILS/src/templates/opac/parts/result/table.tt2
Open-ILS/src/templates/opac/parts/searchbar.tt2
Open-ILS/src/templates/opac/results.tt2

index daa26e5..9a2858c 100644 (file)
     is_advanced = CGI.param("_adv").size;
     is_special = CGI.param("_special").size;
 
+    #variables to use to remove parameters via mkurk
+    expert_search_parms = ['tag','subfield','term','_special'];
+    general_search_parms = ['page','sort','query'];
+
     # -----------------------------------------------------------------------------
     # mkurl( destination_page, params_to_set, params_to_clear )
     #
index 005b48a..a57a77a 100644 (file)
@@ -62,7 +62,7 @@ BLOCK build_author_links;
                 term = term _ ' ' _ sf;
             END;
         END;
-        url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, ['page', 'expand']);
+        url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, stop_parms.merge(expert_search_parms, general_search_parms));
         author_type = (tlabel || label) | html;
         
         # schema.org changes
index 8b29b6b..9518232 100644 (file)
@@ -24,7 +24,7 @@ BLOCK render_series;
                 total_term = all_terms.join(" ").replace('\s+$', '');
 
                 url = mkurl(ctx.opac_root _ '/results',
-                    { qtype=>'series', query=>total_term }, stop_parms
+                    { qtype=>'series', query=>total_term }, stop_parms.merge(expert_search_parms, general_search_parms)
                 );
                 series = series _ '<a href="' _ url _ '">' _ single_term _ '</a> ';
             END;
index 3914908..21b3e19 100644 (file)
@@ -47,7 +47,7 @@
                 all_terms.push(subfield.textContent.replace('\-', ' ').replace('[#"^$\+,\.:;&|\[\]()]', ''));
                 total_term = all_terms.join(" ").replace('\s+$', '');
             %]
-<a href="[% mkurl(ctx.opac_root _ '/results', {qtype=>'subject', query=>total_term}, stop_parms); %]">[% single_term %]</a>
+<a href="[% mkurl(ctx.opac_root _ '/results', {qtype=>'subject', query=>total_term}, stop_parms.merge(expert_search_parms, general_search_parms)) %]">[% single_term %]</a>
             [%- END;
             IF all_terms.size; "<br/>"; END;
             FOREACH link880 IN graphics;
index 0c0b27c..41ff407 100644 (file)
@@ -296,8 +296,8 @@ END;
         )
 %]
                                                         <div class="results_aux_utils place_hold"><a
-                                                                href="[% mkurl(ctx.opac_root _ '/place_hold', 
-                                                                    {hold_target => rec.id, hold_type => 'T', hold_source_page => mkurl()}) %]" 
+                                                                href="[% mkurl(ctx.opac_root _ '/place_hold',
+                                                                    {hold_target => rec.id, hold_type => 'T', hold_source_page => mkurl()}, ['query']) %]"
                                                                     name="place_hold_link" class="no-dec"><img
                                                                 src="[% ctx.media_prefix %]/images/green_check.png"
                                                                 alt=""/><span class="result_place_hold">[% l('Place Hold') %]</span></a>
index 0359c83..604ddad 100644 (file)
@@ -5,7 +5,7 @@
     [%- END %]
     <div>
         <span class="search_catalog_lbl">[% l('Search the Catalog') %]</span>
-        <a href="[% mkurl(ctx.opac_root _ '/advanced') %]"
+        <a href="[% mkurl(ctx.opac_root _ '/advanced', {}, general_search_parms.merge(expert_search_parms)) %]"
             id="home_adv_search_link"><span
             class="adv_search_font">[% l('Advanced Search') %]</span></a>
     </div>
index d199ce9..de67d78 100644 (file)
@@ -27,7 +27,7 @@
                     <a href="[% mkurl(ctx.opac_root _ '/home', {$loc_name => loc_value}, 1) %]">[% l('Another Search') %]</a>
                 </div>
                 <div class="results_header_btns">
-                    <a href="[% mkurl(ctx.opac_root _ '/advanced') %]">[% l('Advanced Search') %]</a>
+                    <a href="[% mkurl(ctx.opac_root _ '/advanced',{}, general_search_parms.merge(expert_search_parms)) %]">[% l('Advanced Search') %]</a>
                 </div>
                 [% IF ctx.mylist.size %]
                 <div class="results_header_btns cached_list_div">