Magento – Newsletter Subscribe Form in Footer or Header

Written by Adrian Hart

Topics: Magento

It used to be the case that to move your Newsletter Subcribe form, or other Magento blocks, from their original position in your Magento template you would need to go and find the relevant lines in the layout XML files and modify them to show in a new postition. This however was a tedious process; especially when it came to precise positioning on your page.

Now you can create a block on the fly and position it precisely in your template files with one line of code. So here it is…


<?php echo $this->getLayout()->createBlock('newsletter/subscribe')->setTemplate('newsletter/subscribe.phtml')->toHtml(); ?>

This code can be used for other types of block. Say you had a template file which would call a list of products from the catalogue, you would use createBlock(‘catalog/product_list’)

5 Comments Comments For This Post I'd Love to Hear Yours!

  1. sven says:

    Yay, that line of code really saved my day! Thanks for sharing that! Btw.: works on Magento 1.7.0 within my footer.phtml

  2. Sanket says:

    It is very helpful to me… Thank You Very Much….
    Keep It Up….

  3. GCSkye says:

    Seems to be working perfectly on Magento 1.7.2, thank you! Messing with this now :]

  4. Kitz says:

    That is the best option ive ever seen. Thank you! you saved me hours for this…

  5. Naveen says:

    Its help me a lot ! you saved me hours for this…

Leave a Comment Here's Your Chance to Be Heard!