I am more familar with jQuery and since mootools is hardcoded in phpwcms I need an easy switch without including jQuery in Template Header and without using the noConflict() mode.
If Oliver provides an optional use of other JS Libraries in future, these scripts are obsolete!
Some explaination:
The corescript is /template/inc_script/frontend_render/jQueryKit.php
1. initialize the Lightbox (and this load mootools or later jQuery - so both scripts are always present in your site! If you don't want that keep away from this script But in case you want to use other Scripting on your site it's ok to load the full library)
2. then the variable which holds the mootools lib will be overwritten with jQuery lib (you can load it from your own server for sure! here I use the google service)
3. then overwrite the slimbox variable with the jquery Version of Light/Slimbox - no need to change anything else it's will work with the css.
Just Olivers localization in his mootools slimbox.js is gone. (no [SCHLIESSEN x] Button anymore
4. it loads a custom.js which holds some other jQuery calls for slideshows or such stuff you may not need it
5. include the frontend_edit.js to keep the frontend edit buttons/function.
Code: Select all
<?php
initializeLightbox(); // this call initMootools() and lightbox JS globally
// now replace the mootools lib with jQuery any following mootools script will broke!
$block['custom_htmlhead']['mootools.js'] = getJavaScriptSourceLink('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js');
// replace the lightbox script with jQuery version
$block['custom_htmlhead']['slimbox.js'] = getJavaScriptSourceLink('template/slimbox/js/jQslimbox.js');
// load one custom JS with all libaries and scripts
$block['custom_htmlhead']['custom.js'] = getJavaScriptSourceLink('template/inc_js/custom.js');
// load the new jQuery frontend edit
if(FE_EDIT_LINK) {
$block['custom_htmlhead']['frontend_edit.js'] = getJavaScriptSourceLink('template/inc_js/frontend_edit.js');
}
?>
I've included all necessary scripts and some more.
The replacement for slimbox without overwrite your orginal mootools slimbox
The Frontend Edit functionality and a custom.js with some helper functions and a simple slideshow function with a simple template for CP Images Special.
It should work out of the box.
It handle the hardcoded Frontend Edit mootools JS - so you don't need to edit the index.php
For explaination see templates/inc_js/frontend_edit.js (it just fakes the addEvent() function
If you have accidently any other mootools scripts loaded (at example the inline JS from slider.tpl) then nothing happens!
no warning/errors - you can turn it on in development process - see the commented addEvent() functions in custom.js
I need to say I don't want to publish this as a bulletproof solution - it's just to illustrate how easy it is to extend phpwcms for your own needs.
Feel free to use it or not. For me it's an easy way to work with jQuery (or any other Lib) without messing around with noConflict() Mode of jQuery with mootools or additional markup in phpwcms templates to include the script...
cheers m.