I have problems with javascript because I want to use lightbox2 and it is using higher versions of prototype and scriptaculous than silverstripe is using. Can anybody tell me how to properly install lightbox without adding much more javascript libraries and getting not into conflict with different versions of libraries.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
The version of prototype in jsparty is very old. Your best bet is to block it on the front end and include your newer prototype (or jquery);
function init() {
parent::init();
Requirements::block("jsparty/prototype.js");
Requirements::javascript("themes/blackcandy/javascript/blah.js");
}
what file do you put this script in to block js?
It should go in the controller class of the page you want to block the scripts on.
So if it is on all pages, it should be in Page_Controller, which is in /mysite/code/Page.php
Cheers,
Mo
Hi Mo,
Thaks again dude. I am despersately trying to get a prettyphoto pop up on my home page with a youtube link.. but seems to be problematic.. maybe jquery problem...
have you tried Nicolaas prettyphoto module by any chance. I am going to give it a go but it does not have instructions with it and don't want to mes my project up.
I haven't tried it unfortunately, I usually hand code lightboxes using one type of jquery plugin or another (there are so may).
If you have both Jquery and prototype loaded on the page, they will conflict. The problem is that $() wont work, instead you have to use jquery().
Is prototype being loaded into your page from the prettyphoto module? I don't know why it would be included otherwise?
I got it sorted in the end by doing this. using pretty photo to launch the youtube video.
Had to get new version of prettyphoto that supports youtube link. wworked out fine.
public function init()
{
parent::init();
self::prototype2jquery();
self::includeForPrettyPhoto();
}
private static function prototype2jquery() {
Requirements::block('jsparty/prototype.js');
Requirements::javascript('jsparty/jquery/jquery.js');
}
private static function includeForPrettyPhoto()
{
Requirements::block('image_gallery/javascript/prettyphoto/jquery.prettyPhoto.js');
Requirements::javascript('jsparty/jquery/jquery.prettyPhoto.js');
Requirements::javascript('image_gallery/javascript/prettyphoto/prettyphoto_init.js');
Requirements::css('themes/tutorial/css/prettyPhoto.css');
}