Newsletter Subscribe Form in Footer or Header

It used to be the case that to move your Newsletter
Subscribe 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 position.
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’)

Advertisements

One thought on “Newsletter Subscribe Form in Footer or Header

  1. Pingback: Add Custom “Sort By” Drop Down menu options In Magento | Magento For Fresher

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s