0

I'm currently developing a eCommerce system with Magento. I have my footer called as <?php echo $this->getChildHtml('footer') ?> and my layout.xml has following tags to define the 'footer'

<reference name="footer">
  <block type="page/footer" name="footer">
    <action method="setTemplate">
      <template>page/html/footer_home.phtml</template>
    </action>
    <action method="setTemplate">
      <template>muaw/footer_script.phtml</template>
    </action>
  </block>
</reference>

footer_home.phtml is the actual footer and footer_script.phtml is a file with <script> tag for some jquery. My problem is that adding the second set of <action> tags for footer_script.phtml replace the actual footer. Is there any other way to get both files?

3
  • Since footer will always show in site, and u have script in <script> tag right, it means its js file, no php code right? so, just add <action method="addJs"> <script>js/custom-script.js</script> </action> and put that js in js folder.
    – Niraj Jani
    Commented Mar 25, 2015 at 12:15
  • good idea. but i don't think that is the best practice. thanx anyway. Commented Mar 25, 2015 at 12:43
  • You're calling two times the setTemplate() method on the page/footer block. This does not make any sense because that block can only have one template, not two. Calling the method twice with a different tamplate parameter therefore renders one of them useless. Therefore it's obvious for whatever what you've tried to do, you've used the wrong tool.
    – hakre
    Commented Mar 25, 2015 at 13:32

2 Answers 2

0

You don't need to set two templates for the footer. Just refrence your phtml file like so...

<reference name="footer">
    <block type="page/footer" name="footer">
        <action method="setTemplate">
            <template>page/html/footer_home.phtml</template>
        </action>
    </block>
    <block type="core/template" name="footer_script" template="muaw/footer_script.phtml"/>
</reference>
0

You should add footer_script.phtml to

<reference name="before_body_end">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.