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.

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.

Template Questions /

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

Shadowbox, fancybox, thickbox ANYTHING!!!!


Go to End


6 Posts   3776 Views

Avatar
daveywilks

Community Member, 3 Posts

6 September 2009 at 7:31am

Hi Folks,

I've been converting my company's website over to Silverstripe for the last few weeks.
I've done most of it and the SS system is great, now it's time for me to add some of the extra touches.

One thing we had on the old site is a link that brings up a thickbox that contains a list of files to download.

I can't for the life of me get any modal boxes working with Silverstripe, just can't figure it out so I'm here asking for help!!!

I've tried using the requirements to add the Javascript, added them directly in the templates and several other things after scouring the web for the last few days.

Could someone supply some pointers to how to do this?

I've found postings with init code but I'm unsure of where it's supposed to go (http://www.silverstripe.org/template-questions/show/256571)

Just a few pointers as to what code goes where to bring up a modal box would be great from someone!!

Thanks in advance,

Dave

Avatar
Willr

Forum Moderator, 5523 Posts

6 September 2009 at 5:10pm

I've found postings with init code but I'm unsure of where it's supposed to go

init() is the function that is always called on your controller. So putting that code as your init() in /mysite/code/Page.php in the Page_Controller section then the javascript will be included on every page of your website.

You should be able to use most libraries without a hassle. You might want to check it is not conflicting with any prototype / SilverStripe JS which is included on the page.

For example from one of my projects I used fancy zoom and I included it this way..

// in my mysite/code/page.php file inside the Page_Controller class
function init() {
		 parent::init();

		// LightBox Code
		Requirements::javascript('themes/themename/javascript/jquery.js');
		 Requirements::javascript('themes/themename/javascript/fancyzoom.js');
		 Requirements::themedCSS('fancyzoom');
}

Also make sure you have FireBug installed as this will make debugging / investigating what is going wrong a heck of alot easier.

Avatar
daveywilks

Community Member, 3 Posts

7 September 2009 at 1:33am

Thanks for the input.

One thing I don't get is that when you put the requirements in there, according to chromes debug tools, it loads the .js stuff at the end of the page meaning that when i try to run the scripts it doesn't work!

Any ideas?

Avatar
daveywilks

Community Member, 3 Posts

7 September 2009 at 4:48am

Well, I got Shadowbox working by linking to the Javascript in the .ss file, not ideal but it works!
Know I just need to figure out how to display another ss page inside the box, at the moment linking to www.google.com opens in a box but if I try to link to another page on the site it just opens the link like normal!!!

Bugger!

Avatar
Willr

Forum Moderator, 5523 Posts

7 September 2009 at 9:45am

it loads the .js stuff at the end of the page

It is good practice to load your js at the bottom of the file. See http://developer.yahoo.com/performance/rules.html#js_bottom for more information on why you would do it.

If you want to disable it you can set this in your _config file.

Requirements::set_write_js_to_body(true);

Avatar
hank1000

Community Member, 5 Posts

29 September 2009 at 4:30am

Hi looks like you now what your doing can you help me i dont now were to start with lightbox2 i use it on my normal site other words not cms and can get it to work fine but having prob here.