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
Comment #1
wlgrana commentedHere 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);
}
Comment #2
yukare commentedWhat 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.
Comment #3
Anonymous (not verified) commentedThis 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 )
Comment #4
Anonymous (not verified) commented^
Comment #5
dan.mantyla commentedThe 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:
added to the top of template.php
Hope this helps someone!!