Improve search term propagation from page to page
authorsenator <lebbeous@esilibrary.com>
Tue, 15 Mar 2011 17:47:10 +0000 (13:47 -0400)
committersenator <lebbeous@esilibrary.com>
Tue, 15 Mar 2011 17:47:10 +0000 (13:47 -0400)
Also, for things like the author link on the record detail page, build a
link with 'qtype=author&query=JK Rowling' instead of 'query=au:JK Rowling'

The latter works, but causes the search form to look stupid.
Query type dropdown will be set to keyword by default, and the term will
be "au:JK Rowling", which will be a head scratcher for 99% of real
users.

Open-ILS/web/templates/default/opac/myopac/circs.tt2
Open-ILS/web/templates/default/opac/myopac/holds.tt2
Open-ILS/web/templates/default/opac/myopac/main.tt2
Open-ILS/web/templates/default/opac/parts/header.tt2
Open-ILS/web/templates/default/opac/parts/record/summary.tt2
Open-ILS/web/templates/default/opac/parts/result/table.tt2
Open-ILS/web/templates/default/opac/parts/searchbar.tt2
Open-ILS/web/templates/default/opac/results.tt2

index d5602be..8846bdf 100644 (file)
                             name="author">
                             <a href="[% ctx.opac_root %]/record/[% circ.circ.target_copy.call_number.record.id %]" name="[% l('Catalog record') %]">[% attrs.title %]</a>
                             [% IF attrs.author %] /
-                            <a href="[% ctx.opac_root %]/results?query=au:[% attrs.author | replace('[,\.:;]', '') | url %]">[% attrs.author %]</a>
+                            <a href="[% ctx.opac_root %]/results?qtype=author&query=[% attrs.author | replace('[,\.:;]', '') | url %]">[% attrs.author %]</a>
                             [% END %]
                         </td>
                         <td width="8%" name="renewals" align="center">
index 79e3044..d0dd325 100644 (file)
                     </td>
                     <td width="123">
                         <div style="margin-top:10px;margin-bottom:10px;">
-                            <a href="[% ctx.opac_root %]/results?query=au:[% attrs.author | replace('[,\.:;]', '') | url %]">[% attrs.author | html %]</a>
+                            <a href="[% ctx.opac_root %]/results?qtype=author&query=[% attrs.author | replace('[,\.:;]', '') | url %]">[% attrs.author | html %]</a>
                         </div>
                     </td>
                     <td width="64">
index 0c307f0..b2e4a2f 100644 (file)
                             </td>
                             <td>
                                 <a class="classic_link"
-                                    href="[% ctx.opac_root %]/results?query=au:[% attrs.author | replace('[,\.:;]', '') | url %]">[% attrs.author %]</a>
+                                    href="[% ctx.opac_root %]/results?qtype=author&query=[% attrs.author | replace('[,\.:;]', '') | url %]">[% attrs.author %]</a>
                             </td>
                             <td name='myopac_circ_trans_start'>
                                 [% date.format(
index 03dbcf1..fa775b2 100644 (file)
@@ -8,6 +8,17 @@
     # Don't wrap in l() here; do that where this format string is actually used.
     SET HUMAN_NAME_FORMAT = '[_1] [_2] [_3] [_4] [_5]';
 
+    # x and y are artifacts of using <input type="image" /> tags instead of
+    # true submit buttons, and their values are never used. page is used, but
+    # currently none of the use cases for rendering the query_string back
+    # into page output call for propagating the value of the page variable.
+
+    query_string = CGI.query_string |
+        replace(';x=\d+','') | replace(';y=\d+','') | replace(';page=\d*', '') |
+        replace(';', '&');
+
+    propagator = '?' _ query_string;
+
     formats = [  # XXX KCLS-specific
         {'code' => 'a', 'name' => 'Book', 'image' => 'media_book.jpg'},
         {'code' => 'i', 'name' => 'Book on cassette', 'image' => 'media_bookoncasset.jpg'},
index 63c1daf..9a6ed0b 100644 (file)
@@ -30,7 +30,7 @@
                             <span class='opac-auto-030'>[% l("Author") %]:</span>
                             <em><a title='[% l("Perform an author search") %]'
                                     id='rdetail_author'
-                                    href="[% ctx.opac_root %]/results?query=author%3a[% attrs.author | replace('[,\.:;]', '') | uri %]&loc=[% loc %]">[% attrs.author %]</a>
+                                    href="[% ctx.opac_root %]/results?qtype=author&query=[% attrs.author | replace('[,\.:;]', '') | uri %]&loc=[% CGI.param('loc') | uri %]">[% attrs.author %]</a>
                             </em>
                             [% END %]
                         </td>
@@ -38,7 +38,7 @@
                             <div style="width:230px;text-align:left;margin-top:3px;">
                                 <div style="float:right;">
                                     <div class="rdetail_aux_utils opac-auto-010">
-                                        <a href="[% ctx.opac_root %]/place_hold?hold_target=[% record.id %]&hold_type=T" id="rdetail_place_hold"><img
+                                        <a href="[% ctx.opac_root %]/place_hold[% propagator; propagator.length > 1 ? "&" : ""; %]hold_target=[% record.id %]&hold_type=T" id="rdetail_place_hold"><img
                                             src="[% ctx.media_prefix %]/images/green_check.png" alt="[% l('place hold') %]" />
                                             <span style="position:relative;top:-3px;left:3px;">Place Hold</span></a>
                                     </div>
                                 </div>
                             </td>
                             <td width="1" valign="top" align="right" style="white-space:nowrap;">
-                                <a href="[% ctx.opac_root %]/place_hold?hold_target=[% record.id %]&hold_type=T"><img alt="[% l('Place Hold') %]"
+                                <a href="[% ctx.opac_root %]/place_hold[% propagator; propagator.length > 1 ? "&" : ""; %]hold_target=[% record.id %]&hold_type=T"><img alt="[% l('Place Hold') %]"
                                     src="[% ctx.media_prefix %]/images/place_hold.gif" /></a>
                                 <a href="#" id="rd_reviews_and_more" target="_blank"><img
                                     alt="[% l('Reviews and More') %]" src="[% ctx.media_prefix %]/images/reviews.gif" /></a>
index 1358ecb..b4ef916 100644 (file)
@@ -1,7 +1,5 @@
 [%  PROCESS "default/opac/parts/marc_misc.tt2";
 
-    np_link = '?' _ query_string;
-
     ctx.result_start = 1 + ctx.page_size * page;
     ctx.result_stop = 1 + ctx.page_size * (page + 1);
     IF ctx.result_stop > ctx.hit_count; ctx.result_stop = ctx.hit_count; END;
@@ -26,7 +24,7 @@
                 <span class='start_end_links_span'>
                     [% IF page > 0 %]
                     <a class='search_page_nav_link'
-                        href="[% np_link _ '&page=' _ (page - 1) %]"
+                        href="[% propagator _ '&page=' _ (page - 1) %]"
                         title='[% l("Previous page") %]'>
                         <span class="nav_arrow_fix">&#9668;</span> Previous
                     </a>
@@ -37,7 +35,7 @@
                     </span>
                     [% IF (page + 1) < page_count %]
                     <a class='search_page_nav_link'
-                        href="[% np_link _ '&page=' _ (page + 1) %]"
+                        href="[% propagator _ '&page=' _ (page + 1) %]"
                         title='[% l("Next page") %]'>
                         Next <span class="nav_arrow_fix">&#9658;</span>
                     </a>
@@ -78,7 +76,7 @@
                                             <td class='result_table_pic_header'
                                                 width="78" nowrap="nowrap" valign="top">
                                                 [% ident = attrs.isbn_clean || attrs.upc; IF ident; %]
-                                                <a href="[% ctx.opac_root %]/record/[% rec.bre.id %]"><img alt="Image of item"
+                                                <a href="[% ctx.opac_root %]/record/[% rec.bre.id _ propagator %]"><img alt="Image of item"
                                                         name='item_jacket' class='result_table_pic' width="55"
                                                         src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/[% ident %]' /></a><br />
                                                 [% END %]
@@ -88,7 +86,7 @@
                                                 valign="top">
                                                 <div class="bold">
                                                     <a title="[% attrs.title %]" name='item_title'
-                                                        href="[% ctx.opac_root %]/record/[% rec.bre.id %]"
+                                                        href="[% ctx.opac_root %]/record/[% rec.bre.id _ propagator %]"
                                                         class='search_link'>[% attrs.title %]</a>
                                                 </div>
                                                 <span style="font-size:11px;">
@@ -96,7 +94,7 @@
                                                         <em>
                                                             <a title="[% l("Perform an Author Search") %]"
                                                                 name='item_author'
-                                                                href="[% ctx.opac_root %]/results?query=author%3a[% attrs.author | replace('[,\.:;]', '') | uri %]&loc=[% loc %]"
+                                                                href="[% ctx.opac_root %]/results?qtype=author&query=[% attrs.author | replace('[,\.:;]', '') | uri %]&loc=[% CGI.param('loc') | uri %]"
                                                                 class='search_link'>[% attrs.author %]</a>
                                                         </em> &nbsp;&nbsp;
                                                         [% attrs.pubdate %]
                                                 <div style="width:250px;text-align:left;">
                                                     <div style="float:right;">
                                                         <div class="results_aux_utils opac-auto-010"><a
-                                                                href="[% ctx.opac_root %]/place_hold?hold_target=[% rec.bre.id %]&hold_type=T" name="place_hold_link" class="no-dec"><img
+                                                                href="[% ctx.opac_root %]/place_hold[% propagator; propagator.length > 1 ? "&" : ""; %]hold_target=[% rec.bre.id %]&hold_type=T" name="place_hold_link" class="no-dec"><img
                                                                 src="[% ctx.media_prefix %]/images/green_check.png"
                                                                 alt="place hold" /><span
                                                                     style="position:relative;top:-3px;left:3px;">Place Hold</span></a>
index 8e9d787..84ab264 100644 (file)
@@ -48,7 +48,7 @@
             </td>
             <td>
                 <span id='depth_selector_span'>
-                    [% PROCESS build_org_selector name='loc' value=loc %]
+                    [% PROCESS build_org_selector name='loc' value=CGI.param('loc') %]
                 </span>
                 <span id='lib_selector_span'>
                     <a id='lib_selector_link' class='classic_link'
index 444995a..19735e2 100644 (file)
@@ -6,11 +6,7 @@
     ctx.page_title = l("Search Results");
     is_advanced = CGI.param("_adv").size;
 
-    query_string = CGI.query_string |
-        replace(';x=\d+','') | replace(';y=\d+','') | replace(';page=\d*', '') |
-        replace(';', '&');
     page = CGI.param('page') || 0;
-    loc = CGI.param('loc');
     page_count = POSIX.ceil(ctx.hit_count / ctx.page_size);
 %]
     <form action="[% ctx.opac_root %]/results" method="GET">