Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » JavaScript, lightbox

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

Page: 1
Go to End
Author Topic: 2224 Views
  • la_fayette
    Avatar
    Community Member
    5 Posts

    JavaScript, lightbox Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: JavaScript, lightbox Link to this post

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

  • zim
    Avatar
    Community Member
    135 Posts

    Re: JavaScript, lightbox Link to this post

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

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: JavaScript, lightbox Link to this post

    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

  • zim
    Avatar
    Community Member
    135 Posts

    Re: JavaScript, lightbox Link to this post

    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.

  • Mo
    Avatar
    Community Member
    508 Posts

    Re: JavaScript, lightbox Link to this post

    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?

  • zim
    Avatar
    Community Member
    135 Posts

    Re: JavaScript, lightbox Link to this post

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

    2224 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.