Skip to main content
Commonmark migration
Source Link

I successfully added some custom JS and CSS to my head section (look here).

But If I try to add a script at the block before_body_end then I get:

There has been an error processing your request
  
Invalid method Mage_Core_Block_Text_List::addItem(Array
(
    [0] => skin_js
    [1] => black/NewsletterPopup/js/main.js
)

app\design\frontend\base\default\layout\black\newsletter_popup.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addItem">
                <type>skin_js</type>
                <script>black/NewsletterPopup/js/jquery.magnific-popup.min.js</script>
            </action>
            <action method="addCss">
                <stylesheet>black/NewsletterPopup/css/magnific-popup.css</stylesheet>
            </action>
            <action method="addCss">
                <stylesheet>black/NewsletterPopup/css/main.css</stylesheet>
            </action>
        </reference>

        <reference name="before_body_end">
            <action method="addItem">
                <type>skin_js</type>
                <script>black/NewsletterPopup/js/main.js</script>
            </action>
        </reference>
    </default>
<!-- ... -->

I successfully added some custom JS and CSS to my head section (look here).

But If I try to add a script at the block before_body_end then I get:

There has been an error processing your request
 Invalid method Mage_Core_Block_Text_List::addItem(Array
(
    [0] => skin_js
    [1] => black/NewsletterPopup/js/main.js
)

app\design\frontend\base\default\layout\black\newsletter_popup.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addItem">
                <type>skin_js</type>
                <script>black/NewsletterPopup/js/jquery.magnific-popup.min.js</script>
            </action>
            <action method="addCss">
                <stylesheet>black/NewsletterPopup/css/magnific-popup.css</stylesheet>
            </action>
            <action method="addCss">
                <stylesheet>black/NewsletterPopup/css/main.css</stylesheet>
            </action>
        </reference>

        <reference name="before_body_end">
            <action method="addItem">
                <type>skin_js</type>
                <script>black/NewsletterPopup/js/main.js</script>
            </action>
        </reference>
    </default>
<!-- ... -->

I successfully added some custom JS and CSS to my head section (look here).

But If I try to add a script at the block before_body_end then I get:

There has been an error processing your request
 
Invalid method Mage_Core_Block_Text_List::addItem(Array
(
    [0] => skin_js
    [1] => black/NewsletterPopup/js/main.js
)

app\design\frontend\base\default\layout\black\newsletter_popup.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addItem">
                <type>skin_js</type>
                <script>black/NewsletterPopup/js/jquery.magnific-popup.min.js</script>
            </action>
            <action method="addCss">
                <stylesheet>black/NewsletterPopup/css/magnific-popup.css</stylesheet>
            </action>
            <action method="addCss">
                <stylesheet>black/NewsletterPopup/css/main.css</stylesheet>
            </action>
        </reference>

        <reference name="before_body_end">
            <action method="addItem">
                <type>skin_js</type>
                <script>black/NewsletterPopup/js/main.js</script>
            </action>
        </reference>
    </default>
<!-- ... -->
Post Closed as "Duplicate" by Marius
Source Link
Black
  • 3.4k
  • 4
  • 40
  • 123

Magento 1.8 - How to addItem to block other than `head`?

I successfully added some custom JS and CSS to my head section (look here).

But If I try to add a script at the block before_body_end then I get:

There has been an error processing your request
Invalid method Mage_Core_Block_Text_List::addItem(Array
(
    [0] => skin_js
    [1] => black/NewsletterPopup/js/main.js
)

app\design\frontend\base\default\layout\black\newsletter_popup.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addItem">
                <type>skin_js</type>
                <script>black/NewsletterPopup/js/jquery.magnific-popup.min.js</script>
            </action>
            <action method="addCss">
                <stylesheet>black/NewsletterPopup/css/magnific-popup.css</stylesheet>
            </action>
            <action method="addCss">
                <stylesheet>black/NewsletterPopup/css/main.css</stylesheet>
            </action>
        </reference>

        <reference name="before_body_end">
            <action method="addItem">
                <type>skin_js</type>
                <script>black/NewsletterPopup/js/main.js</script>
            </action>
        </reference>
    </default>
<!-- ... -->