Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
PTiCA1 Posted June 12, 2016 Posted June 12, 2016 Hello, How can I modify or add new javascript into my new template? The documentation I found the procedure only to the plugin. Thank you for your help
Meddysong Posted June 14, 2016 Posted June 14, 2016 It's just a case of adding <script type='text/javascript' src='{setting="base_url"}path/to/js/file.js' data-ips></script> into a template. Probably the most logical place is at the end of core > global > global > includeJS
PTiCA1 Posted June 15, 2016 Author Posted June 15, 2016 Thanks for the backlash. There url to retrieve a file from a template?
Meddysong Posted June 15, 2016 Posted June 15, 2016 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.)
PTiCA1 Posted June 15, 2016 Author Posted June 15, 2016 {{$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
Meddysong Posted June 15, 2016 Posted June 15, 2016 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!)
Bluto Posted November 28, 2018 Posted November 28, 2018 {{$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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.