0

I have created a custom module on frontend that is showing data from DB on now i want to add jquery and style sheet to my custom module front page.

I have tried like this through my layout xml but it is not including.

<?xml version="1.0"?>   
  <layout version="0.1.0">   
     <reviews_index_index>   
        <reference name="root">   
           <action method="setTemplate"><template>page/1column.phtml</template></action>   
        </reference>   
        <reference name="content">   
           <block type="reviews/index" name="reviews_index" template="reviews/index.phtml"/>   
        </reference>   
         <reference name="head">
            <action method="addItem">
                <type>js</type>
                 <name>reviews/reviews.js</name>
            </action>
         </reference> 
    </reviews_index_index>  

 </layout>   
  • Which file is not including? reviews.js? – tjons Nov 28 '16 at 21:16
  • i have updated the question yes it is – Xabby Nov 28 '16 at 21:17
1

If the JS is contained in the skin files, you need to use addItem('skin_js', 'path/relative/to/jsdir.js'). In your case, it would be like this:

<action method="addItem">
    <type>skin_js</type><name>reviews/reviews.js</name>
</action>
  • it is here: skin\frontend\rwd\default\js\reviews – Xabby Nov 28 '16 at 21:20
  • Ah. Well, then, you have to use addItem('skin_js') – tjons Nov 28 '16 at 21:21
  • like this: <action method="addItem"><type>skin_js</type><name>reviews/reviews.js</name></action – Xabby Nov 28 '16 at 21:23
  • @Xabby yep. Just like that. – tjons Nov 28 '16 at 21:24
  • Except don't forget the closing > after the action. Does that work? – tjons Nov 28 '16 at 21:25

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.