HACK: Use hardcoded fi:format selector
authorJeff Godin <jgodin@tadl.org>
Wed, 3 Oct 2012 18:08:01 +0000 (14:08 -0400)
committerJeff Godin <jgodin@tadl.org>
Thu, 18 Oct 2012 04:18:21 +0000 (00:18 -0400)
This is a hack / proof of concept which may be rendered unnecessary
by changes in post-2.2 releases of Evergreen.

The intent is to allow searching for "E-Books" and "Large Print
Books" by switching to a "format" search filter instead of an
"item_type" filter.

We are hardcoding the choices of format, and generating the <select>
using item_format_selector.tt2, which is a modified version of
coded_value_selector.tt2.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
css/tadl.css
templates_tadlskin/opac/parts/item_format_selector.tt2 [new file with mode: 0644]
templates_tadlskin/opac/parts/searchbar.tt2

index 0ebdaef..37c5afe 100644 (file)
@@ -1585,6 +1585,7 @@ a.preflib_change {
 #ac_content { clear: both; width: 100%; margin-top: 10px; }
 
 select#qtype,
+select#item_format_selector,
 select#location_selector {
     width:auto;
 }
diff --git a/templates_tadlskin/opac/parts/item_format_selector.tt2 b/templates_tadlskin/opac/parts/item_format_selector.tt2
new file mode 100644 (file)
index 0000000..234af73
--- /dev/null
@@ -0,0 +1,31 @@
+
+[%
+# These are displayed in the order shown
+item_formats = [
+    { 'code' => 'at', 'value' => 'Books' },
+    { 'code' => 'at-d', 'value' => 'Large Print Books' },
+    { 'code' => 'at-s', 'value' => 'E-Books' },
+    { 'code' => 'i', 'value' => 'Audiobooks' },
+    { 'code' => 'g', 'value' => 'Video Recordings' },
+    { 'code' => 'j', 'value' => 'Music' },
+    { 'code' => 'm', 'value' => 'Electronic Resources' },
+];
+%]
+
+[%-
+    name = "fi:format";
+    id = "item_format_selector";
+    values = values || CGI.param(name);
+-%]
+
+<select id='[% id %]' name='[% name %]'[%
+    multiple ? ' multiple="multiple"' : '';
+    size ? (' size="' _ size _ '"') : ''; %]>
+[% IF none_ok %]
+    <option value=''>[% none_label ? none_label : l('-- Any --') %]</option>
+[% END;
+FOR o IN item_formats; %]
+    <option value='[% o.code | uri %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : '' %]>[% o.value | html %]</option>
+[%  END -%]
+</select>
+
index b47e3ae..da24ffe 100644 (file)
@@ -28,7 +28,7 @@
     </div>
     <div class="searchbar">
         [%- INCLUDE "opac/parts/qtype_selector.tt2" id="qtype"; %]
-        [%- INCLUDE "opac/parts/coded_value_selector.tt2" attr=["mattype", "item_type"] none_ok=1 none_label=l('All Formats'); %]
+        [%- INCLUDE "opac/parts/item_format_selector.tt2" none_ok=1 none_label=l('All Formats'); %]
         [%- INCLUDE build_org_selector show_loc_groups=1 id='location_selector' %]
     </div>
     [% IF ctx.bookbag %]