21285 Posts in 5732 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 637 Views |
-
How in the world do I implement this?

2 May 2009 at 10:32am
Okay, I've been up awhile and my brian is a little slow, however I must be missing something on the scale of Cloverfield.
I would like to implement this: http://www.lokeshdhakar.com/projects/lightbox2/
Where do you put the javascript to get executed? Where does the Requirements::javascript get put?
It seems so very simple to implement but it has taken me the better part of today to get even broken.
Any hep would be so appreciated.
Terry
-
Re: How in the world do I implement this?

2 May 2009 at 11:48am
Hey Terry,
On the page type you would like to add the JS (or if its on every page) just put Requirements::javascript( - link to file - ); for each JS file you need to include in the function init() in the Controller of the page. If you need to load a CSS file you can use Requirements::css()
Confused? Maybe an example will help. This is what we use in the forum to load custom JS and CSS
...
class ForumHolder_Controller extends Page_Controller {function init() {
Requirements::themedCSS('Forum'); // loads themes/your_theme/css/Forum.css
Requirements::javascript("jsparty/jquery/jquery.js");
Requirements::javascript("forum/javascript/jquery.MultiFile.js");
Requirements::javascript("forum/javascript/forum.js");
parent::init(); // you must have this line
}
... -
Re: How in the world do I implement this?

2 May 2009 at 12:43pm
willr,
Thanks a million for this.
I know it's simple, but I must be missing something.
I have in my Page.php the following:
class Page_Controller extends ContentController {
public function init() {
//Sifr::add_font('trade', 'themes/rittheme/fonts/tradegothic.swf');
Sifr::replaceElement(".Title","SolexMinLin",'sColor:"#007CA8",sLinkColor:"#fe6e0e",sHoverColor:"#fe6e0e"');
Sifr::loadSifr();
// Note: you should use SS template require tags inside your templates
// instead of putting Requirements calls here. However these are
// included so that our older themes still work
Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");
Requirements::themedCSS("lightbox");
Requirements::javascript( "mysite/javascript/jquery.js" );
Requirements::javascript( "mysite/javascript/jquery.lightbox.js" );
parent::init();
}It doesn't fire. I did the ?flush=1 I basically did exactly what the lightbox2 code has and it looks correct when I view source. Weird.
here's my page... Is there something I'm missing?
http://63.247.208.15/dose-calibration/
Terry
PS. I really appreciate you helping out on this.
-
Re: How in the world do I implement this?

2 May 2009 at 8:18pm
Have you got the firebug plugin for firefox? its essential for doing any sort of webdevelopment work. One thing it shows is the JS error console, and the errors on a page. If your sites case I can see it has 1 error - $(document).ready is not a function - so it seems like maybe how this is implemented is incorrect or maybe the prototype code SS has is conflicting. See http://doc.silverstripe.com/doku.php?id=jquery for an example jquery file and try that
-
Re: How in the world do I implement this?

3 May 2009 at 3:23pm
Yes....Thank you willr.
I got it to work.
I so appreciate you helping everyone out. This is going to make the client exceedingly happy. Plus, it opens up SS to all kinds of jquery utilities.
Thanks again,
Terry
| 637 Views | ||
|
Page:
1
|
Go to Top |


