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?

1 Answer 1

3

Ok so the setTemplate method sets the template on the parent block in this case name="footer". As it can only have one template that is then overwritten by the second method call.

What you need to do is something like this:

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

That will set the main template for the footer to page/html/footer_home.phtml and give it a child block of muaw/footer_script.phtml.

You then need to call that child block from within muaw/footer_script.phtml by adding this code to it: <?php echo $this->getChildHtml("footer_script");?>

If you want to seperate the two blocks you can add a seperate block for each and then call then from within the footer template.

Your Answer

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

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