2011-06-30 31 views
3

如何在添加複選框功能,當它檢查電子郵件聯繫我們形式訂閱通訊?通訊聯繫我們在magento

+0

超載Mage_Contacts_IndexController http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_overload_a_controller ,放在postAction功能這些線 if($ post ['is_subscribed'] == 1){status = Mage :: getModel('newsletter/subscriber') - > subscribe($ post ['email']); } –

回答

0

編輯的聯繫方式,並添加自己的複選框,然後修改使用上述(Mage_Contacts_IndexController)的方法接觸控制器

這樣,你會加入一些代碼中使用的電子郵件地址從訂閱電子報發佈形式:

$status = Mage::getModel('newsletter/subscriber')->subscribe($email); 
if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) { 
    Mage::getSingleton('core/session') 
     ->addSuccess($this->__('Confirmation request has been sent.')); 
} 
else { 
    Mage::getSingleton('core/session') 
     ->addSuccess($this->__('Thank you for your subscription.')); 
}