TPAC: This expands the 'awards' tab by default on the record detail page tpac-expand-awards-by-default
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 17 Apr 2013 20:31:29 +0000 (16:31 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 17 Apr 2013 20:31:29 +0000 (16:31 -0400)
And it also gives you a framework for expanding other tabs by default.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/templates/opac/parts/record/extras.tt2

index a6100f1..00e084a 100644 (file)
@@ -1,6 +1,8 @@
 [%
     arrow_img = ctx.media_prefix _ '/images/rdetail_arrow.png';
     arrow_down_img = ctx.media_prefix _ '/images/rdetail_arrow_down.png';
+
+    expand_by_default = {"awards" => 1};
 %]
 <div>
     <div id='rdetail_extras_div' style='width: 100%;'> 
@@ -25,6 +27,7 @@
         MACRO tab_is_active(tab) BLOCK;
             exp_name = 'expand_' _ tab;
             IF ctx.$exp_name OR ctx.expand_all; 1; END;
+            IF expand_by_default.$tab AND NOT CGI.param('close_' _ tab); 1; END;
         END;
 
         # Let's see if we should hide the content cafe / simple summary content
             <div class="rdetail_extras_link">
                 [%  
                     IF tab_is_active(name);
-                        href = mkurl('', {}, ['expand', 'ac']);
+                        add_to_href = {};
+                        IF expand_by_default.$name;
+                            close_key = 'close_' _ name;
+                            add_to_href.$close_key = 1;
+                        END;
+                        href = mkurl('', add_to_href, ['expand', 'ac']);
                         img_url = arrow_down_img;
                     ELSE;
                         IF name == 'addedcontent' AND default_ac;
                             href = mkurl('', {expand => name, ac => default_ac}) _ '#' _ name; 
                         ELSE;
-                            href = mkurl('', {expand => name}) _ '#' _ name; 
+                            close_name = 'close_' _ name;
+                            href = mkurl('', {expand => name}, [close_name]) _ '#' _ name;
                         END;
                         img_url = arrow_img;
                     END;