Page 1 of 1

[SOLVED]How to reference a js file with a root variable?

Posted: Thu May 16, 2013 2:51 pm
by blackhawk
Within my template I have the following script tag..

Code: Select all

<__script__ type='text/javascript' src='/dev2/uploads/js/jquery-1.8.3.min.js'></__script>
which works no matter what page I go to under my site.

But if I change it to...

Code: Select all

<__script__ type='text/javascript' src='uploads/js/jquery-1.8.3.min.js'></__script>
...then jQuery is only detected on the home page. FYI - I am using $config['url_rewriting'] = 'mod_rewrite';

Is there anyway I can write something like this in my template...

Code: Select all

<__script__ type='text/javascript' src='{root_url}/uploads/js/jquery-1.8.3.min.js'></__script>
When I try this, it fails on me as well. The point being is that I don't want to keep manually changing this path every time I move my cmsms site from my local host to my live server. I want it to reference the js scripts under my uploads directory, for any page I land on.

Thanks!

Re: How to reference a js file with a root variable?

Posted: Thu May 16, 2013 2:58 pm
by blackhawk
Actually, that works! But I thought that just failed on me. So my apologies! Problem solved!

Re: [SOLVED]How to reference a js file with a root variable?

Posted: Thu May 16, 2013 3:14 pm
by calguy1000
{uploads_url} would work too.
Which would be cool if you ever renamed your uploads path/uploads_url in the config.php (i.e: for a pseudo CDN).

Re: [SOLVED]How to reference a js file with a root variable?

Posted: Thu May 16, 2013 3:41 pm
by blackhawk
now that's more direct! awesome, thank you!