Javascript EE Template Basics
Posted: 20 June 2006 05:05 PM   [ Ignore ]  
Summer Student
Total Posts:  27
Joined  02-01-2006

Hey all, trying to incorporate my javacript that works on static pages that I’ve created locally.  However seem to be having problems.  I’m sure it’s releated to the way EE references the path to the javascript.

what I’ve done:

In the template group i’ve created a new template called tz.js.

Normally you would access it this way:

•script language="JavaScript"  type="text/javascript" src="tz.js"></script•

How do you specify it in EE to load the file.

thanks.

Profile
 
 
Posted: 20 June 2006 05:33 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1454
Joined  09-16-2004

Weird I cannot find this in the docs. There is a page about linking to stylesheets but nothing about Javascript.
So make that 2 who are curious smile

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 20 June 2006 05:35 PM   [ Ignore ]   [ # 2 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32852
Joined  05-14-2004

You do it the way you posted in your first post.  Only, instead you can put the JS into a template of type javascript, then use:

<script language="javascript"  type="text/javascript" src="{path=tempategroup/templatename}"></script>

Alternatively, you could just use a a slash at the beginning and give it a root-relative URL

<script language="javascript"  type="text/javascript" src="/ts.js"></script>

 Signature 
Profile
MSG
 
 
Posted: 20 June 2006 05:47 PM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1454
Joined  09-16-2004

Clocked in under 2 minutes, thanks a lot Lisa!

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 20 June 2006 06:30 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  27
Joined  02-01-2006

thanks for the info Lisa.  Put me in the right direction.

Profile
 
 
Posted: 26 February 2008 09:41 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  12
Joined  02-11-2008

This hasn’t worked for me. Here’s my code:

<!--[if lte IE 6]>
<
script language="javascript" type="text/javascript" src="{path=site/supersleight-min}"></script>
<![endif]-->

I have a JavaScript template called supersleight-min in the site template group. The template has nothing but straight js in it. The code that is being spit out in the source is this:

<!--[if lte IE 6]>
<
script language="javascript" type="text/javascript" src="http://www.btbab.org/index.php/site/supersleight-min/"></script>
<![endif]-->

Am I missing something?

Profile
 
 
Posted: 27 February 2008 08:16 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  300
Joined  07-31-2007

I know it’s not exactly what you’re looking for but it might be an alternative worth investigating… I like to keep anything not directly related to dynamic content (ie. javascript, CSS, PHP classes) out of EE and I include my javascript in templates like that:

src="{site_url}_js/jquery.js"

I don’t seem to have any problem with this setup, and it’s a little more flexible that /file.js depending on your setup…

 Signature 

——————————————————-
ExpressionEngine 1.6.2 - Build:  20080206

Profile
 
 
Posted: 03 March 2008 07:25 AM   [ Ignore ]   [ # 7 ]  
Grad Student
Avatar
Rank
Total Posts:  99
Joined  03-08-2006

Or you could take it a step further and wrench all javascript files out of EE and upload them via ftp and reference to them via an absoloute path from your template. I’ve encountered a lot js misbehaviouras if I let EE deal with my javascript. Especially, if you’ve got more than one js file that you want to play with.

Also, a word of warning on a bug I encountered with supersleight.js on IE6: it clashes with Mark Hout’s handy Geo Coding plugin.

 Signature 

Seb Neerman

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64883 Total Logged-in Users: 67
Total Topics: 81809 Total Anonymous Users: 36
Total Replies: 439800 Total Guests: 319
Total Posts: 521609    
Members ( View Memberlist )
Newest Members:  Hotcards.comShrike67Dynamic1justingpticketjendicottdxrsmdanbilly8hrkiliwysso