Lightbox 2 / SimpleX issue fixed

This article is also available in: Deutsch

I’ve spent some time finding out, why none of the lightbox plugins worked on my wordpress 2.7 blog site and as strange as it sounds: it’s the theme. I use SimpleX.
This theme uses a version of jQuery and creates an object refering to by $.

$(function(){
var tabContainers = $(‘div#maintabdiv > div’);
tabContainers.hide().filter(‘#comments’).show();

$(‘div#maintabdiv ul#tabnav a’).click(function () {
tabContainers.hide();
tabContainers.filter(this.hash).show();
$(‘div#maintabdiv ul#tabnav a’).removeClass(‘current’);
$(this).addClass(‘current’);
return false;
}).filter(‘#comments’).click();

});

The problem is, lightbox (or rather the prototype.js it requires) also uses that variable name $.
The solution for this problem is, to rename the variable the theme uses:

mjq(function(){
var tabContainers = mjq(‘div#maintabdiv > div’);
tabContainers.hide().filter(‘#comments’).show();

mjq(‘div#maintabdiv ul#tabnav a’).click(function () {
tabContainers.hide();
tabContainers.filter(this.hash).show();
mjq(‘div#maintabdiv ul#tabnav a’).removeClass(‘current’);
mjq(this).addClass(‘current’);
return false;
}).filter(‘#comments’).click();

});

Just edit /wp-content/themes/simplex/header.php by replacing the first by the second text mentioned above.

The only thing left to do is telling the jQuery SimpleX uses to not look for $ but for mjq. Therefore edit /wp-content/themes/simplex/js/jquery-1.2.6.min.js (or similar) replace the following:

var _jQuery=window.jQuery,_$=window.$;byvar _jQuery=window.jQuery,_mjq=window.mjq;
var jQuery=window.jQuery=window.$=function(selector,context)byvar jQuery=window.jQuery=window.mjq=function(selector,context)
window.$=_$;bywindow.mjq=_mjq;

Then you have a functioning WordPress running SimpleX and Lightbox.

attached files
mod_simplex_files

1 Response » to “Lightbox 2 / SimpleX issue fixed”

  1. [...] Volgens sommigen zijn er natuurlijke betere oplossing, die bijvoorbeeld beter geprogrammeerd zijn of veiliger zijn. WordPress heeft echter zo’n grote community achter zich dat bijna elk probleem die je tegenkomt al door iemand anders weer opgelost is. Om bijvoorbeeld de veiligheid te testen is er de WordPress Scanner. Zelf had ik een probleem dat Lightbox 2 (een plugin voor foto’s) niet werkte met mijn thema SimpleX, na een rondje google-en was er al iemand met een oplossing. [...]

Leave a Reply