0

I added these custom js and css file:

  1. skin/frontend/base/default/black/NewsletterPopup/js/main.js

  2. skin/frontend/base/default/black/NewsletterPopup/css/main.js

Then I included them via my modules layout file

app/design/frontend/base/default/layout/black/newsletter_popup.phtml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addJs">
                <script>black/NewsletterPopup/js/main.js</script>
            </action>
            <action method="addCss">
                <stylesheet>black/NewsletterPopup/css/main.css</stylesheet>
            </action>
        </reference>
    </default>
<!-- ... -->

But a network analysis showed that the files could not be found and if I enter the link to the file directly into the URL then the "404 Sorry page not found" page shows up.

What am I doing wrong?

0

I had to change

<action method="addJs">
    <script>black/NewsletterPopup/js/main.js</script>
</action>

which actually targets the {magentoroot}/js folder, to

<action method="addItem">
    <type>skin_js</type>
    <script>black/NewsletterPopup/js/main.js</script>
</action>

which targets the skin folder.

  • yes, it should work. – kunj Jun 4 '18 at 12:34
0

Try this :

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addItem">
                  <type>skin_js</type>
                  <script>black/NewsletterPopup/js/main.js</script>
            </action>
            <action method="addItem">
                 <type>skin_css</type>
                  <name>black/NewsletterPopup/css/main.css</name> 
                 <params/>
             </action>

        </reference>
    </default>
<!-- ... -->
  • This is just a copy from my answer.? Or not? – Black Jun 4 '18 at 12:37
  • No, I have not copy your answer, I just check in Magento 1.9.3. I have added for CSS also. Even take time to format my answer. – kunj Jun 4 '18 at 12:39
  • It is not needed for CSS though, I tried it and it also works with addCss somehow. – Black Jun 4 '18 at 12:41
  • You can add media="all" extra param by skin_css public function addItem($type, $name, $params=null, $if=null, $cond=null) { if ($type==='skin_css' && empty($params)) { $params = 'media="all"'; } $this->_data['items'][$type.'/'.$name] = array( 'type' => $type, 'name' => $name, 'params' => $params, 'if' => $if, 'cond' => $cond, ); return $this; } – kunj Jun 4 '18 at 12:44
-1

Your layout file should be a .xml file and not .phtml file :

(app/design/frontend/base/default/layout/black/newsletter_popup.phtml)

  • Thats incorrect. – Black Jun 4 '18 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.