In order to disable lightbox functionality in mobile theme or another theme you can do:

in template.php file :

function phptemplate_preprocess_page(&$vars) {
// Disable lightbox
$lightbox = drupal_get_path('module', 'lightbox2');
$scripts = drupal_add_js();
unset($scripts['module'][$lightbox . '/js/lightbox.js']);
$vars['scripts'] = drupal_get_js('header', $scripts);
return $vars;
}

Comments

wlgrana’s picture

Here is the code i use to detect iOS and disable lightbox.js

// Detect iOS and disable lightbox.js
$browserAsString = $_SERVER['HTTP_USER_AGENT'];
if (strstr($browserAsString, " AppleWebKit/") && strstr($browserAsString, " Mobile/"))
{
$css = drupal_add_css();
$scripts = drupal_add_js();
unset($css['all']['module']['modules/node/node.css']);
unset($scripts['module']['sites/all/modules/lightbox2/js/lightbox.js']);
$vars['styles'] = drupal_get_css($css);
$vars['scripts'] = drupal_get_js('header', $scripts);
}

yukare’s picture

What do you think about make this a setting? A textbox where admin can enter a list of user agents where lightbox will not load? Something near as we have to not load lighbox on specific pages.

Anonymous’s picture

This should be done easily in the admin interface under -> "PAGE SPECIFIC LIGHTBOX2 SETTINGS" if they would only accept absolute paths then you could add the m.SITE.com/* ( which would help if you are using different urls for your mobile site )

Anonymous’s picture

Category: task » feature

^

dan.mantyla’s picture

Issue summary: View changes

The code posted above would not work for me. Maybe because that was posted 4 years ago..

Here's what I needed to do to get this working, use drupal's new hook_js_alter() hook like this:

function fusion_core_js_alter(&$javascript) {
    $ismobile = check_user_agent('mobile'); //this is a utility function I added, not a drupal function
    if ($ismobile) {
    	$lightbox = drupal_get_path('module', 'lightbox2');
	$javascript[$lightbox.'/js/lightbox.js']['data'] = NULL;
    }
}

added to the top of template.php

Hope this helps someone!!