Warning: Use of undefined constant wp_cumulus_widget - assumed 'wp_cumulus_widget' (this will throw an Error in a future version of PHP) in /home/blogoptimise/public_html/wp-content/plugins/wp-cumulus/wp-cumulus.php on line 375
Optimise Blog » Magento – Newsletter Subscribe Form in Footer or Header
Warning: Use of undefined constant style - assumed 'style' (this will throw an Error in a future version of PHP) in /home/blogoptimise/public_html/wp-content/themes/optimblog/functions.php on line 522

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]

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

[/php]

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’)

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