[VUFIND-50] Switching between themes Created: 10/Feb/09  Updated: 04/May/12  Resolved: 04/May/12

Status: Resolved
Project: VuFind®
Components: User Interface
Affects versions: None
Fix versions: 2.0alpha

Type: Improvement Priority: Major
Reporter: inga overkamp Assignee: Andrew Nagy
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original estimate: Not Specified

Issue links:
incorporate
incorporates VUFIND-246 Change Template Links to include them... Closed

 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 :)


 Comments   
Comment by Luke O'Sullivan [ 11/Sep/09 ]
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.
Comment by Andrew Nagy [ 18/Dec/09 ]
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.
Comment by Luke O'Sullivan [ 02/Jun/10 ]
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'];
                }
            }
        }
Comment by Demian Katz [ 04/May/12 ]
As of r5563, VuFind 2.0 has configurable support for multiple themes with an optional drop-down list for selecting a theme. This complements the existing mobile device detection.
Generated at Thu Mar 28 13:15:01 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100248-rev:e207e3a88e19bebfd0fd5834088a20d22d89a0a2.