Adding js file in the head

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Locked
Nicoow
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Sep 01, 2010 12:43 pm

Adding js file in the head

Post by Nicoow » Wed Sep 01, 2010 12:52 pm

Hi,

I've been assigned to do some problem solving for a Joomla site.
Now i need a .js file to be included in the head of the site.
Now i tried it hard coded: <script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/menu.js"></script>

I tried it with Document:
<?php
$document = &JFactory::getDocument();
$document->addScript( '/templates/tb-home/js/menu.js );
?>

And with JHTML:
<?php
$filename = 'menu.js';
$path = 'templates/tb-home/js/';
JHTML::script($filename, $path);
?>

I just added this in the head of the main index file.
But it only adds some extra white spaces, but no <script ty.......> is show in the websites source.

How can i solve this problem, or what amm i doing wrong?

User avatar
imanickam
Joomla! Master
Joomla! Master
Posts: 28202
Joined: Wed Aug 13, 2008 2:57 am
Location: Chennai, India

Re: Adding js file in the head

Post by imanickam » Wed Sep 01, 2010 1:01 pm

Try the following:

Code: Select all

<script language="javascript" type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/menu.js"></script>
What is your site URL?
Ilagnayeru (MIG) Manickam | இளஞாயிறு மாணிக்கம்
Joomla! - Global Moderators Team | Joomla! Core - Tamil (தமிழ்) Translation Team Coordinator
Former Joomla! Translations Coordination Team Lead
Eegan - Support the poor and underprivileged

Nicoow
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Sep 01, 2010 12:43 pm

Re: Adding js file in the head

Post by Nicoow » Wed Sep 01, 2010 1:05 pm

It needs to be kept secret, that's what they want, so i can't give it.
It's on a test1.domain.com. don't know if that can screw it up?

Still doesn't work.
I changed my code to:
<!--Here's should be my import line-->
<script language="javascript" type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/menu.js"></script>
<!--And this would be the end of it-->

And in my source code of the site it displays:
<!--Here's should be my import line-->

<!--And this would be the end of it-->

Does any one know a way to solve, somebody said i could try it with a module or something.
But how can i load a module in the <head> part?


Locked

Return to “Templates for Joomla! 1.5”