0

in cake we use

$this->html->script('jsfilenamewithdotjs');

to add an external js file to a view How'd we do that with lithium

Mehdi Lahmam B.
  • 2,240
  • 16
  • 22
Asim Zaidi
  • 27,016
  • 49
  • 132
  • 221

1 Answers1

5

echo $this->html->script('jquery.js'); returns a <script /> tag. If the filename is prefixed with "/", the path will be relative to the base path of your application. Otherwise, the path will be relative to your JavaScript path, usually webroot/js.

For an external script $this->html->script('http://foo.com/bar.js');

Docs: http://li3.me/docs/lithium/template/helper/Html::script()

botero
  • 598
  • 2
  • 11
  • 23
Mehdi Lahmam B.
  • 2,240
  • 16
  • 22
  • 2
    If you are running a site that operates on both http and https, you can use `$this->html->script('//foo.com/bar.js');` to have the external script use the same protocol as the page. You can also use `$this->html->script('//foo.com/bar.js', array('inline' => false);` to not output the script right away. And then in your layout file, call `echo $this->scripts();` to have all of the scripts echoed out that you've queued up by setting `'inline'` to `false`. There are some notes about this in the Views section of the manual - http://lithify.me/docs/manual/handling-http-requests/views.wiki – rmarscher Jun 22 '12 at 14:45