如何在magento中创建取消订阅页面

如何在magento中创建取消订阅页面,magento,newsletter,unsubscribe,Magento,Newsletter,Unsubscribe,我想在magento中创建一个直接退订页面,我发现需要遵循此说明,但步骤1和2不清楚,因为我不是专业人士。 有人能帮我澄清这两个步骤吗。在哪里创建“unsubscribe.phtml”页面?如何在其中添加刚创建的块? 提前谢谢你。 1.创建一个phtml页面,说“unsubscribe.phtml”,其中包含创建取消订阅表单的代码 <?php $newsletterObj = new Mage_Newsletter_Block_Subscribe(); ?> <div clas

我想在magento中创建一个直接退订页面,我发现需要遵循此说明,但步骤1和2不清楚,因为我不是专业人士。 有人能帮我澄清这两个步骤吗。在哪里创建“unsubscribe.phtml”页面?如何在其中添加刚创建的块? 提前谢谢你。
1.创建一个phtml页面,说“unsubscribe.phtml”,其中包含创建取消订阅表单的代码

<?php $newsletterObj = new Mage_Newsletter_Block_Subscribe(); ?>
<div class="newsletter-unsubscribe">
<div class="newsletter-unsubscribe-title"><?php echo $this->__('Submit your email id to unsubscribe newsletter') ?></div>
<form action="<?php echo $newsletterObj->getUnsubscribeFormActionUrl() ?>” method="post" id="newsletter-validate-detail">
<div class="block-content">
<div class="input-box">
<input type="text" name="email" id="newsletter" title="<?php echo $this->__('Sign up for our newsletter') ?>” class="input-text required-entry validate-email” value="<?php echo $this->__('Enter Your Email Here') ?>” onfocus="if(this.value==’<?php echo $this->__('Enter Your Email Here') ?>’)this.value=’’;” onblur="if(this.value==’’)this.value=’<?php echo $this->__('Enter Your Email Here') ?>’;”
/>
</div>
<div class="actions">
<button type="submit" title="<?php echo $this->__('Submit') ?>” class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
</div>
</div>
</form>
<script type="text/javascript\">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm(’newsletter-validate-detail’);
//]]>
</script>
</div>
5) 现在在\app\code\core\Mage\newress\controllers\SubscriberController.php页面中添加取消订阅进程的新操作

/** *从前端取消订阅时事通讯 */


因为a不能留下评论,而且这个问题还没有标记为已解决,所以我假设您仍然需要答案

我建议将
unsubscribe.phtml
文件放在
/template/newsletter/

对于步骤2,您可以使用此代码

{{block type=“core/template”template=“newsletter/unsubscribe.phtml”}

因此,页面将包含您的表单


如果你已经想出了如何做到这一点,请张贴你自己的问题进一步回答

在subscribe按钮旁边添加一个unsubscribe按钮(或者在block调用中允许一个变量将其设置为yes/no display),这样您就可以同时捕获这两个按钮了

<div class="unsubscribe">
<a href="<?php echo Mage::getUrl('unsubscribe-newsletter') ?>"><?php echo $this->__('Unsubscribe') ?></a>
</div>
public function getUnsubscribeFormActionUrl()
{
return $this->getUrl(’newsletter/subscriber/unsubscribecus’, array(’_secure’ => true));
}
public function unsubscribecusAction()
{
$email = $this->getRequest()->getParam(’email’);
$subsModel = Mage::getModel(’newsletter/subscriber’);
$subscriber = $subsModel->loadByEmail($email);

$id = (int) $subsModel->getId();
$code = (string) $subsModel->getCode();
if ($id && $code) {
$session = Mage::getSingleton(’core/session’);
try {
Mage::getModel(’newsletter/subscriber’)->load($id)
->setCheckCode($code)
->unsubscribe();
$session->addSuccess($this->__(’You have been unsubscribed.’));
}
catch (Mage_Core_Exception $e) {
$session->addException($e, $e->getMessage());
}
catch (Exception $e) {
$session->addException($e, $this->__(’There was a problem with the un-subscription.’));
}
}
$this->_redirectReferer();
}