[Koha-patches] [PATCH] Bug 9558 - Customize CSS for mobile

Zachary Spalding oleonard at myacpl.org
Fri May 17 20:35:08 CEST 2013


It is possible to use an environment variable to specify a custom
stylesheet for different libraries in a multi-library system:
$ENV{'OPAC_CSS_OVERRIDE'}. This patch adds an additional option to
override the CCSR theme's mobile stylesheet.

To test:

- Create a custom stylesheet and add it alongside CCSR's other CSS
  files.
- Add a simple CSS rule which will be obvious in testing. For example:

    form#searchform { background-color: red; }

- Modify the configuration file for your OPAC to add a line
  specifying a new custom stylesheet:

    SetEnv OPAC_CSS_OVERRIDE_MOBILE <name of CSS file>

- Restart Apache.

- Switch the OPAC theme to 'CCSR'
- Clear your browser cache
- View any page in the OPAC. If you browser is wider than 700 pixels the
  OPAC should appear normal. Below 700 pixels wide you should see your
  custom CSS applied (a red background on the search bar if you used the
  above example.

The changes in this patch are courtesy Zachary Spalding as described in
Bug 9558. Patch and test plan created by Owen Leonard.
---
 C4/Auth.pm                                         |    1 +
 .../opac-tmpl/ccsr/en/includes/doc-head-close.inc  |    3 +++
 2 files changed, 4 insertions(+)

diff --git a/C4/Auth.pm b/C4/Auth.pm
index ca061b5..ea269db 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -416,6 +416,7 @@ sub get_template_and_user {
             OPACBaseURL               => ($in->{'query'}->https() ? "https://" : "http://") . $ENV{'SERVER_NAME'} .
                    ($ENV{'SERVER_PORT'} eq ($in->{'query'}->https() ? "443" : "80") ? '' : ":$ENV{'SERVER_PORT'}"),
             opac_css_override         => $ENV{'OPAC_CSS_OVERRIDE'},
+            opac_css_override_mobile  => $ENV{'OPAC_CSS_OVERRIDE_MOBILE'},
             opac_search_limit         => $opac_search_limit,
             opac_limit_override       => $opac_limit_override,
             OpacBrowser               => C4::Context->preference("OpacBrowser"),
diff --git a/koha-tmpl/opac-tmpl/ccsr/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/ccsr/en/includes/doc-head-close.inc
index fcbab2a..eb71770 100644
--- a/koha-tmpl/opac-tmpl/ccsr/en/includes/doc-head-close.inc
+++ b/koha-tmpl/opac-tmpl/ccsr/en/includes/doc-head-close.inc
@@ -18,6 +18,9 @@
         <link rel="stylesheet" type="text/css" href="[% themelang %]/css/[% opaccolorstylesheet %]" />
     [% END %]
 [% END %]
+[% IF ( opac_css_override_mobile ) %]
+    <link rel="stylesheet" type="text/css" media="screen and (max-width:700px)" href="[% themelang %]/css/[% opac_css_override_mobile %]" />
+ [% END %]
 [% IF ( opac_css_override ) %]
     <link rel="stylesheet" type="text/css" href="[% themelang %]/css/[% opac_css_override %]" />
 [% END %]
-- 
1.7.9.5


More information about the Koha-patches mailing list