Question about adding custom javascript to template

Everything to do with Joomla! 3.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Post Reply
aballevar
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Tue Jun 12, 2018 4:25 pm

Question about adding custom javascript to template

Post by aballevar » Fri Jul 13, 2018 4:12 pm

I´m working in a Joomla! Template and am wondering: Why the javascript in the site doesn´t work if the file is inside a folder in the root folder of the template ? Why only works if the javascript file is on the root folder of the template?
This is when I declared the javascript on my index.php when the file is on a folder:

Code: Select all

 <script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/js/main.js" type="text/javascript"></script>
This is when I declared the javascript on my index.php when the file is on the root folder:

Code: Select all

 <script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/main.js" type="text/javascript"></script>

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 24616
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: Question about adding custom javascript to template

Post by Per Yngve Berg » Fri Jul 13, 2018 9:27 pm

How does it look in the source code of the rendered page?


Post Reply

Return to “Templates for Joomla! 3.x”