I am trying to load js file in the footer of my magento. I am using this code but it give me back an error. Any help? Thanks a lot!
code used in local.xml:
<layout>
<default>
<reference name="footer">
<action method="addJs"><script>js/file.js</script></action>
</reference>
</default>
</layout>
Find page.xml
of your theme and find the following
<block type="core/text_list" name="before_body_end" as="before_body_end" translate="label">
And insert the following code after that
<block type="page/html_head" name="jsfooter" as="jsfooter" template="page/html/jsfooter.phtml">
<action method="addJs"><script>your_script.js</script></action>
</block>
Create the template file in app/design/frontend/[package]/[theme]/template/page/html/jsfooter.phtml
and put the following:
<?php echo $this->getCssJsHtml() ?>
In your page template files “1column.phtml”, “2columns-left.phtml”, “2columns-right.phtml”, “3columns.phtml” and etc. you will need to output this block before tag:
<?php echo $this->getChildHtml('jsfooter') ?>
For Magento v1.6+ (need to test in older versions);
1 - create an template file in page/html/footer/extras.phtml
with this content:
<?php echo $this->getCssJsHtml() ?>
2 - Add this html node to your layout xml:
<reference name="before_body_end">
<block type="page/html_head" name="extra_js" as="extraJs" after="-" template="page/html/footer/extras.phtml">
<action method="addItem"><type>skin_js</type><name>js/jquery.min.js</name></action>
</block>
3 - That is it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With