1
Shiva
Including javascript
  • 2009/9/28 18:53

  • Shiva

  • Quite a regular

  • Posts: 280

  • Since: 2006/7/9 1


Hi All,

I need to include javascript into my code but I also need to pass a smarty variable (namely $xoops_url). So the only way I can see to do this is by putting the code into theme.html. But I would much rather include a path to the js file to make the code cleaner.

Right now I have temporarily hard coded the path instead of putting it into theme.html.

Any suggestions?

Thanks in advance.


2
ghia
Re: Including javascript
  • 2009/9/28 22:45

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


In your theme you can do this:
le="color: #000000"><?php <script type=text/javascript> var XoopsPath = <{$xoops_url}>; </script> <script type=text/javascript src=test.js></script>
In eg. test.js, you can then make use of the XoopsPath variable.

3
Shiva
Re: Including javascript
  • 2009/9/29 7:24

  • Shiva

  • Quite a regular

  • Posts: 280

  • Since: 2006/7/9 1


That's brilliant - Thank you!