Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » add external files

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

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

Page: 1
Go to End
Author Topic: 2276 Views
  • satpal
    Avatar
    Community Member
    13 Posts

    add external files Link to this post

    can anyone tell me how can i add an external file like html file ,.js etc in silverstripe

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: add external files Link to this post

    Could you explain a bit more?

    for adding in a js file you can generally do something like this in your Page_Controller init():

    Requirements::javascript ("mysite/javascript/myjsfile.js");

    see: http://doc.silverstripe.com/doku.php?id=requirements

    For including html, not sure what you mean, normally html goes into the templates...

  • microcarl
    Avatar
    Community Member
    4 Posts

    Re: add external files Link to this post

    what if i want to add an external Javascript file like the google maps file?

    Requirements::javascript("http://maps.google.com/maps?file=api&v=2.x&key=....");

    doesnt work because it generates code like this:

    <script type="text/javascript" src="http://sandbox.micromusic.org/http://maps.google.com/maps?file=api&amp;v=2&amp;key=..."></script>

    Any help appreciated!

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: add external files Link to this post

    You can always put it in the template...

  • microcarl
    Avatar
    Community Member
    4 Posts

    Re: add external files Link to this post

    so there is no way to add an external script in the code? like with

    Requirements::...

    ??

    right?

    i just saw that in the "maps" module all google script have been included like this and didnt work (of course). or can i configure something that paths to JS starting with "http://..." arent linked relatively? but maybe i have to aks & tell the "google map module" people about it.

    thanks dio5 for your help!

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: add external files Link to this post

    Are u sure it really doesn't work, or something else might be causing this?

    I'm using the maps module as well on a site of mine and didn't have any problems with that.

  • microcarl
    Avatar
    Community Member
    4 Posts

    Re: add external files Link to this post

    yes, i tried it yesterday and it always created this useless tags (check src attribute):

    <script type="text/javascript" src="http://mydomain.com/http://www.google.com/....">

    what SS version did you use? i used a pretty new checkout from the SVN. maybe that's the problem because something changed lately in the SVN code? strange anyway.

    2276 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.