magento에서 직접 수신 거부 페이지를 만들고 싶습니다.이 지침을 따르지만 1 단계와 2 단계는 분명하지 않습니다. 전문가가 아니기 때문에. 누군가이 두 단계를 명확하게 설명 할 수 있습니까? "unsubscribe.phtml"페이지를 만들 위치는 어디입니까? 그냥 방금 만든 블록을 추가하는 방법? 미리 감사드립니다.
1. unsubscribe 양식을 작성하는 코드가 들어있는 phtml 페이지 "unsubscribe.phtml"을 작성하십시오.magento에서 수신 거부 페이지를 만드는 방법
<?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>
2) CMS 페이지를 만듭니다. 방금 생성 된 블록을 추가하십시오. 그러면 CMS 페이지에 해당 양식이 포함됩니다.
3) 이제 \ app \ design \ frontend \ base \ default \ template \ newsletter \ subscribe.phtml 페이지에 cms 페이지의 링크를 추가하는 코드를 추가하십시오. 페이지 \ 응용 프로그램 \ 코드 \ 코어 \ 마법사 \ 뉴스 \ 블록 \ Subscribe.php에서
<div class="unsubscribe">
<a href="<?php echo Mage::getUrl('unsubscribe-newsletter') ?>"><?php echo $this->__('Unsubscribe') ?></a>
</div>
4)는 "unsubscribe.phtml"에서 호출되는 형태의 액션 URL을 생성하는 기능을 추가 할 수 있습니다. 이제 \ 응용 프로그램의 \ 코드 \ 코어 \ 마법사 \ 뉴스 \ 컨트롤러에서
public function getUnsubscribeFormActionUrl()
{
return $this->getUrl(’newsletter/subscriber/unsubscribecus’, array(’_secure’ => true));
}
5) \ SubscriberController.php 페이지 탈퇴 프로세스에 대한 새로운 액션을 추가 할 수 있습니다. 난 당신이 여전히 필요 가정합니다하는 이후 프론트 엔드 */
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();
}