how to call newsletter/subscribe.phtml on cms/content_home.phtml?

14,163

Solution 1

system -> configuration -> advanced

from there enable newsletter module. and then you can use the above code to call it anywhere.

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

Solution 2

If you look at the newsletter.xml layout update file, you will find the subscribe block defined like this:

<reference name="left">
    <block type="newsletter/subscribe" name="left.newsletter" template="newsletter/subscribe.phtml"/>
</reference>

The easiest thing you can do is add something similar to the Layout Update XML for your homepage. Simply open the homepage in the CMS Pages area of the admin, click on the Design tab, and put this in the Layout Update XML text box:

<reference name="content">
    <block type="newsletter/subscribe" name="home.newsletter" template="newsletter/subscribe.phtml"/>
</reference>

You may need to play around with it to get it to show up where you want, but that should work.

Share:
14,163
atif
Author by

atif

magento, wordpress, custom php/mysql, jquery/Ajax

Updated on June 14, 2022

Comments

  • atif
    atif almost 2 years

    I want to make a newsletter subscription box on home page in content area, and for that I have made a CMS page that other code I have placed in the newsletter subscription file can call too.

    I am trying to call it like this:

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

    but it does not show up.

    Why ?

  • atif
    atif over 12 years
    i know normally we cab do that in both way , one you have mentioned and the other i had mentioned above but rite now i am not getting it either way in magento 1.6 :( don't know why
  • Lajos Mészáros
    Lajos Mészáros over 10 years
    Why isn't there a flippin complete reference of these stuff somewhere on the net??? I'm stuck with magento template creation for over a week now. Had enough of searching for code snippets on forums :(