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

ss fails totally at linking to javascript and css files


Reply


3 Posts   728 Views

Avatar
marcink

Community Member, 89 Posts

31 March 2011 at 8:54pm

hi,

as much as i love ss for its immense possibilities, its ease of use (even if i hate php - its such a ugly language...) as much i hate how it handles requirements.

i was at this point like [url=http://www.silverstripe.org/general-questions/show/6378/]2 years ago[/url] and since then nothing changed.

can any on tell me, how and why a linked js file in a include (.ss) can be above requirements that are defined inside the head tag???
(when i talk about required, i mean: <% required javascript(...) %>)

that's just plain stupid.
i understand that there can be no absolute solution to that. but at least respect that js/css files that are defined as required in the head are please, please be included on top of the other files?

is that really too much asked for??

so, now that i cooled down, is there now a solution to this? did i miss something?

any help appreciated...

Avatar
simon_w

Forum Moderator, 474 Posts

31 March 2011 at 10:20pm

That is the expected behaviour, as it's impossible to know if something included using Requirements is needed for something in those hardcoded blocks to work, they're put above it, just in case.

You can use Requirements::insertHeadTags('<script src="blah.js"></script>'); in the init() method in your Controller subclass to ensure that something goes in the head and doesn't cause other included things to be put before it (it adds right before </head>).

Avatar
marcink

Community Member, 89 Posts

31 March 2011 at 10:38pm

i was just about to clarify my post, as it is indeed confusing.

it's ok to add all js to the end of the html document. i agree with that.
and of course (as i mentioned) ss can not know what order the requirements in some include files should have.

but:
it should be quite obvious, that linked files in the Page.ss or Page.php (or the equivalent - the top most page subclassing Page.php or SiteTree.php)
should be placed on top of others. and all js defined in a include - way down in hirarchy - should be placed belowe.

am i wrong? i can't see a case where this order wouldn't work.

pls tell me your thoughts on this.