format selector gets formats from CCVM fields, starting with 'mattype', falling back...
authorberick <berick@esilibrary.com>
Wed, 20 Apr 2011 15:01:45 +0000 (11:01 -0400)
committerberick <berick@esilibrary.com>
Wed, 20 Apr 2011 15:01:45 +0000 (11:01 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/web/templates/default/opac/parts/format_selector.tt2

index 9577121..524c9a6 100644 (file)
@@ -51,6 +51,7 @@ sub _prepare_biblio_search {
 
     $query = ('#' . $_ . ' ' . $query) foreach ($cgi->param('modifier'));
 
+    # filters
     foreach (grep /^fi:/, $cgi->param) {
         /:(\w+)$/ or next;
         my $term = join(",", $cgi->param($_));
@@ -128,6 +129,8 @@ sub load_rresults {
 
     $query = "$query $facet" if $facet; # TODO
 
+    $logger->activity("EGWeb: [search] $query");
+
     my $results;
 
     try {
index 2ca397b..d52129b 100644 (file)
@@ -1,12 +1,23 @@
-[%-  name = name || "fi:format";
+[% 
+    # Start w/ mattype, fall back to item_type
+    format_spec = '';
+    formats = [];
+    FOR format_spec IN ['mattype', 'item_type'];
+        formats = ctx.search_ccvm('ctype', format_spec);
+        IF formats.size; BREAK; END;
+    END;
+    name = name || "fi:" _ format_spec;
     id = id || "format_selector";
-    values = values || CGI.param(name) -%]
+    values = values || CGI.param(name) 
+-%]
+
 <select id='[% id %]' name='[% name %]'[%
     multiple ? ' multiple="multiple"' : '';
     size ? (' size="' _ size _ '"') : ''; %]>
     <option value=''>[% l("All Formats") %]</option>
+
 [% FOR o IN formats %]
-    <option value='[% o.code %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : ''%]>[% o.name %]</option>
+    <option value='[% o.code %]'[% values.grep('^' _ o.code _ '$').size ? ' selected="selected"' : ''%]>[% o.value %]</option>
 [%- END %]
 <!--
        <option value='at'>[% l("Books") %]</option>