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.

Archive /

Our old forums are still available as a read-only archive.

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

Javascript Best Practices


Reply


5 Posts   1430 Views

Avatar
dio5

Community Member, 501 Posts

20 September 2007 at 7:33pm

Hi again,

I'm probably going to want some custom javascript added to my pages, and probably even some ajax.

Now I'm familiar with using the YUI-library but I see that there's already quite some js ( scriptaculous, prototype ) involved in the CMS.

Is there any place where I can read about the best way to use the js that's already there, or should I just include the other library that I'm used to work with?

And maybe some info about using ajax with SS too...

Avatar
Ingo

Forum Moderator, 801 Posts

21 September 2007 at 1:08am

for the frontend-side of things, you're pretty much free to choose for yourself.
some silverstripe-modules such as blog/pagecomments require prototype/scriptaculous, but they're automatically included.

some info/coding conventions for using javascript with silverstripe (mostly backend-related):
http://doc.silverstripe.com/doku.php?id=javascript
http://doc.silverstripe.com/doku.php?id=coding-conventions&s=javascript

Avatar
dio5

Community Member, 501 Posts

21 September 2007 at 1:22am

Edited: 21/09/2007 1:38am

Ok so I could just as well include the YUI-library I'm used to work with...

Is it common to include this in the page_controller? and how.. ? or just add them to my page.ss.?

Maybe there's some doku about it...?

I guess that's my major problem. I spend more time searching for how to do stuff than on actually writing it. I'm bookmarking every useful page now to prevent loosing time searching for it :-)

Avatar
Ingo

Forum Moderator, 801 Posts

21 September 2007 at 2:16am

class Page extends SiteTree {}
class Page_Controller extends ContentController {
function init() {
parent::init();
Requirements::javascript::('mysite/javascript/yui.js');
);
}

> I guess that's my major problem. I spend more time searching for how to do stuff than on actually writing it.
we're always looking for ways to adjust the wiki to the different learning paths, and are thankful for any tips in this direction - especially on structuring the content on the doc.silverstripe.com startpage.

Avatar
dio5

Community Member, 501 Posts

21 September 2007 at 2:52am

Ok thanks a lot

I've found it also on http://doc.silverstripe.com/doku.php?id=requirements&s=javascript%20required
although that document doesn't say you have to call parent, init.. which can be confusing.

I believe there's quite some documentation out there but it's hard to find sometimes. Maybe a clear link to http://doc.silverstripe.com/doku.php?do=index can be helpful to anyone starting from http://doc.silverstripe.com/doku.php.

What I'd like to see more too is some good explanation of how everythings fits into eachother. I find myself having a hard time knowing when to use what.
Like getComponents, ... there's this tutorial of many_many_examples (http://doc.silverstripe.com/doku.php?id=many_many-example) but that leaves a lot of questions on how to select from multiple tables, when to use DataObject::get instead of getComponent(s), etc.

And maybe some more explanation about authentication, frontend registration etc... Now I'm facing the task of wrestling through the forum code to gain insight in it.

I know it must be a lot of work to get good documentation, but I'm sure that it will make many people happy :-)