Reputation: 1693
I want to add a js file from lib directory and it's path is:
rootdirectory/lib/myfolder/myjs.js
I have added the below code to get that file in 1column.phtml:
<script src="<?php echo Mage::getBaseDir('lib') . '/myfolder/myjs.js'; ?>" type="text/javascript"></script>
But it is not loading the content with the following error below:
Failed to load resource: the server responded with a status of 404 (Not Found)
Though the file is present there.
Upvotes: 0
Views: 957
Reputation: 1104
In .phtml file you need to call the js by following syntax
<?php echo $this->getJsUrl('name.js');?>
This will automatically gets located at js folder of your magento you will just have to name the js you want to load for current file to use it .
Upvotes: 1
Reputation: 172
It is best to move your file to a folder rootfolder/js/ and in your layout (for example local.xml):
<default>
<reference name="head">
<action method="addJs"><script>myfolder/myjs.js</script></action>
</reference>
...
</default>
Upvotes: 1