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

General project discussion. NOT for help questions.
Post Reply
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

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

Post 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!
Last edited by blackhawk on Thu May 16, 2013 2:59 pm, edited 2 times in total.
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

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

Post by blackhawk »

Actually, that works! But I thought that just failed on me. So my apologies! Problem solved!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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).
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

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

Post by blackhawk »

now that's more direct! awesome, thank you!
Post Reply

Return to “General Discussion”