Jump to content

How to added javascript file in my new template


PTiCA1

Recommended Posts

Sorry, my friend, I'm not sure I understand. Do you mean "is there a URL to the JS file?"

It will depend where you store it on your server. If it's at domain.com/uploads/js/my-js-file.js, then you would enter in the template

<script type='text/javascript' src='{setting="base_url"}uploads/js/my-js-file.js' data-ips></script>

({setting="base_url"} gives you domain.com. I use it like that so that nothing goes wrong if I move my site.)

Link to comment
Share on other sites

 

{{$customCss = \IPS\Theme::i()->css( 'custom.css', 'core', 'front' );}}
{{foreach $customCss as $css}}
<link rel='stylesheet' href='{expression="\IPS\Http\Url::external( $css )->setQueryString( 'v', \IPS\SUITE_UNIQUE_KEY )"}' media='all'>
{{endforeach}}

I found a solution for CSS, and exactly same solution I need for Javascript

Link to comment
Share on other sites

That exists because you can create your own custom CSS files when editing a theme. But there's nothing like that for JS.That's why you have to add your JS files manually. (Unless anybody knows any different, in which case I'm happy to learn because I need it too!)

Link to comment
Share on other sites

  • 2 years later...
{{$js = \IPS\Theme::i()->resource( 'folder_in_resources/another_folder/some_js_file.js', 'core', 'front' );}}
<script type="text/javascript" src='{expression="$js->setQueryString( 'v', \IPS\CACHEBUST_KEY )"}'></script>

Using this you can add js files to the theme.  The lines above I included in the includeJS file.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...