Magento - 注册后重定向到成功页面

时间:2014-04-21 10:16:43

标签: php magento action registration

所以,我是magento的新手,我一直试图对我得到的当前代码做一些修改。 我要做的是将用户重定向到新页面并向他们显示一些信息。代码实际上做的是将用户重定向到登录页面并向他显示消息。我在AccountController上找到了这段代码,但我不知道如何创建新页面并将用户重定向到该页面。

protected function _successProcessRegistration(Mage_Customer_Model_Customer $customer)
{
    $session = $this->_getSession();        

    if ($customer->isConfirmationRequired()) {
        /** @var $app Mage_Core_Model_App */
        $app = $this->_getApp();
        /** @var $store  Mage_Core_Model_Store*/
        $store = $app->getStore();
        $customer->sendNewAccountEmail(
            'confirmation',
            $session->getBeforeAuthUrl(),
            $store->getId()
        );
        $customerHelper = $this->_getHelper('customer');
        $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.',
            $customerHelper->getEmailConfirmationUrl($customer->getEmail())));
       $url = $this->_getUrl('*/*/index', array('_secure' => true)); //<---HERE!!!         
    } else {            
        $session->setCustomerAsLoggedIn($customer);
        $session->renewSession();
        $url = $this->_welcomeCustomer($customer);
    }
    $this->_redirectSuccess($url);
    return $this;
}

如何创建新动作并定义一些html,然后重定向到它?我已经尝试在这个控制器上创建一个名为successRegistrationAction()的新函数,但每当我尝试在浏览器上访问它时,我都被重定向到登录操作。

提前致谢

*编辑:

这是我在AccountController.php中的函数:

public function registrationSuccessAction()
{
    $this->loadLayout();
    $this->renderLayout();
}

然后我将其添加到customer.xml:

    <customer_account_registrationsuccess translate="label">
    <label>Customer Account Registration Success</label>
    <!-- Mage_Customer -->
    <remove name="right"/>
    <remove name="left"/>

    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
    <reference name="content">
        <block type="core/template" name="customer_registrationsuccess" template="customer/registrationSuccess.phtml"/>
    </reference>
</customer_account_registrationsuccess>

**修改

我的preDispatch函数(添加了registrationSuccess到数组):

public function preDispatch()
{
    // a brute-force protection here would be nice

    parent::preDispatch();

    if (!$this->getRequest()->isDispatched()) {
        return;
    }

    $action = $this->getRequest()->getActionName();
    $openActions = array(
        'create',
        'login',
        'logoutsuccess',
        'forgotpassword',
        'forgotpasswordpost',
        'resetpassword',
        'resetpasswordpost',
        'confirm',
        'confirmation',
        'registrationsuccess'
    );
    $pattern = '/^(' . implode('|', $openActions) . ')/i';

    if (!preg_match($pattern, $action)) {
        if (!$this->_getSession()->authenticate($this)) {
            $this->setFlag('', 'no-dispatch', true);
        }
    } else {
        $this->_getSession()->setNoReferer(true);
    }
}

0 个答案:

没有答案