VuFind

Switching between themes

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: Wishlist
  • Component/s: User Interface
  • Labels:
    None

Description

Hi,

I hope this is the right way to submit code extensions which might be of interest to other vuFind implementers as well?

Background and requirement: We would like to run one central vuFind installation for the complete MPG, but to offer some localization options (e.g. filter and theme selection) for individual sites or groups of sites. Therefore, we extended the vuFind code slightly to enable switching between themes by providing an additional key-value pair.

Modifications:
 1. web/sys/Interface.php
[...]
        $this->template_dir = "$local/interface/themes/$theme";
        $this->compile_dir = "$local/interface/compile";
        $this->compile_id = $theme;
        $this->cache_dir = "$local/interface/cache";
[...]

 2. web/index.php
[...]
// MPG extension: set theme
if (isset($_GET['mytheme'])) {
    $theme = $_GET['mytheme'];
    setcookie('theme', $theme, null, '/');
} else {
    $theme = (isset($_COOKIE['theme'])) ? $_COOKIE['theme'] :
                    $configArray['Site']['theme'];
}
$local = $configArray['Site']['local'];
$interface->template_dir = "$local/interface/themes/$theme";
$interface->compile_id = $theme;
$interface->assign('userTheme', $theme);
// MPG extension: end
[...]

solution: http://gwda185.gwdg.de/vufind/?mytheme=mpdl

many greetings,
inga

p.s.: please be advised that this was my first php modifcation ever :)

Issue Links

Activity

Hide
Luke O'Sullivan added a comment -
We may be looking to implement a similar system at SWWHEP.

I was unable to view the link posted but would be keen to see it in operation.
Show
Luke O'Sullivan added a comment - We may be looking to implement a similar system at SWWHEP. I was unable to view the link posted but would be keen to see it in operation.
Hide
Andrew Nagy added a comment -
I've tweaked this a bit to allow for on the fly theme changing by editing the config file. No need to clear compile, etc.
Show
Andrew Nagy added a comment - I've tweaked this a bit to allow for on the fly theme changing by editing the config file. No need to clear compile, etc.
Hide
Luke O'Sullivan added a comment - - edited
I have implemented an option to allow users to select their theme (it could be better integrated with the 'ui' cookie which is currently in use):

config.ini - List of Available Themes
theme = multiBlue,multiBlack

Interface.php

        $this->vufindTheme = $configArray['Site']['theme'];
        
        $myThemeArray = explode(',', str_replace (" ", "",$this->vufindTheme));
        $this->assign('myThemes', $myThemeArray); // Makes themes available to templates
        
        // User Defined Theme
        if (isset($_POST['myTheme'])) {
            $myTheme = $_POST['myTheme'];
            setcookie('myTheme', $myTheme, null, '/');
        } else {
            $myTheme = (isset($_COOKIE['myTheme'])) ? $_COOKIE['myTheme'] :
            false;
        }
        
        if($myTheme) {
            $this->vufindTheme = $myTheme;
        }
        else {

            // Use mobile theme for mobile devices (if enabled in config.ini)
            if (isset($configArray['Site']['mobile_theme'])) {
                // If the user is overriding the UI setting, store that:
                if (isset($_GET['ui'])) {
                    $_COOKIE['ui'] = $_GET['ui'];
                    setcookie('ui', $_GET['ui'], null, '/');
                // If we don't already have a UI setting, detect if we're on a mobile
                // and store the result in a cookie so we don't waste time doing the
                // detection routine on every page:
                } else if (!isset($_COOKIE['ui'])) {
                    $_COOKIE['ui'] = mobile_device_detect() ? 'mobile' : 'standard';
                    setcookie('ui', $_COOKIE['ui'], null, '/');
                }
                // If we're mobile, override the standard theme with the mobile one:
                if ($_COOKIE['ui'] == 'mobile') {
                    $this->vufindTheme = $configArray['Site']['mobile_theme'];
                }
            }
        }
Show
Luke O'Sullivan added a comment - - edited I have implemented an option to allow users to select their theme (it could be better integrated with the 'ui' cookie which is currently in use): config.ini - List of Available Themes theme = multiBlue,multiBlack Interface.php         $this->vufindTheme = $configArray['Site']['theme'];                  $myThemeArray = explode(',', str_replace (" ", "",$this->vufindTheme));         $this->assign('myThemes', $myThemeArray); // Makes themes available to templates                  // User Defined Theme         if (isset($_POST['myTheme'])) {             $myTheme = $_POST['myTheme'];             setcookie('myTheme', $myTheme, null, '/');         } else {             $myTheme = (isset($_COOKIE['myTheme'])) ? $_COOKIE['myTheme'] :             false;         }                  if($myTheme) {             $this->vufindTheme = $myTheme;         }         else {             // Use mobile theme for mobile devices (if enabled in config.ini)             if (isset($configArray['Site']['mobile_theme'])) {                 // If the user is overriding the UI setting, store that:                 if (isset($_GET['ui'])) {                     $_COOKIE['ui'] = $_GET['ui'];                     setcookie('ui', $_GET['ui'], null, '/');                 // If we don't already have a UI setting, detect if we're on a mobile                 // and store the result in a cookie so we don't waste time doing the                 // detection routine on every page:                 } else if (!isset($_COOKIE['ui'])) {                     $_COOKIE['ui'] = mobile_device_detect() ? 'mobile' : 'standard';                     setcookie('ui', $_COOKIE['ui'], null, '/');                 }                 // If we're mobile, override the standard theme with the mobile one:                 if ($_COOKIE['ui'] == 'mobile') {                     $this->vufindTheme = $configArray['Site']['mobile_theme'];                 }             }         }

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: