Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

JavaScript, lightbox


Reply


7 Posts   2314 Views

Avatar
stefan.huber

Community Member, 5 Posts

21 June 2009 at 8:33am

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.

Avatar
Willr

Forum Moderator, 5513 Posts

21 June 2009 at 2:41pm

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");
}

Avatar
zim

Community Member, 135 Posts

3 November 2009 at 6:05am

what file do you put this script in to block js?

Avatar
Mo

Community Member, 514 Posts

3 November 2009 at 7:33am

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

Avatar
zim

Community Member, 135 Posts

4 November 2009 at 3:17am

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.

Avatar
Mo

Community Member, 514 Posts

6 November 2009 at 1:38am

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?

Avatar
zim

Community Member, 135 Posts

6 November 2009 at 5:29am

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');
   }