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

风流意气都作罢 提交于 2019-12-11 02:26:11

问题


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 ?


回答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(); ?>



回答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.



来源:https://stackoverflow.com/questions/8165386/how-to-call-newsletter-subscribe-phtml-on-cms-content-home-phtml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!