Magento多个phtml联系表单模板

时间:2016-01-22 06:27:15

标签: php jquery html forms magento

我正在创建多个联系表单并从http://www.milessebesta.com/web-design/magento-make-multiple-contact-us-forms-and-redirect-them-to-a-seperate-thank-you-pages/获取想法。

我创建了多个联系表单,用于快速联系多个页面。一个是弹出窗体,另一个是另一个联系页面。 (PPC目的)

我准备了三个以上的.phtml联系表单模板。这些模板几乎相同,但我添加了其他输入表单。他们使用相同的电子邮件模板,我使用{{if}} {{else}}指令来获取所需的输入值。我还创建了目录并添加了具有.phtml格式的静态块。

我有www.mydomain.com/contacts正常工作,但静态块中包含的联系表单不会发送此www.mydomain.com/catalog/another-contact-page中的表单。

这是我的表单操作和输入隐藏。基于教程。我必须创建一个隐藏了我想要的URL值的输入。

<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post" enctype="multipart/form-data">
<input id="custom_redirect" class="required-entry input-text field" title="<?php echo Mage::helper('contacts')->__('custom_redirect') ?>" type="hidden" name="custom_redirect" value="<?php echo Mage::getBaseUrl(); ?>catalog/another-contact-page">

我还把这段代码放在我的控制器上

if (!$mailTemplate->getSentSuccess()) {
                throw new Exception();
            }

            $translate->setTranslateInline(true);

            if (isset($post['custom_redirect'])) { // If custom_redirect is set

                $redirect_url = $post['custom_redirect']; // Get the URL you want to redirect to

                $redirect_too = (explode(".com.au/", $redirect_url)); // Explode the Url

                Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));

                $this->_redirect($redirect_too[1]); // Redirect to everything everything after .com

                return;

            } else {

                Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));

                $this->_redirect('*/*/');

                return;
            }

问题:

修改后我仍然无法发送联系我们表格。帖子提交在浏览器的某处停止,当尝试刷新页面时,会弹出警告确认表单重新发送

问题:

导致问题的原因是什么?如何使用我的自定义phtml联系表单发送查询电子邮件?

更新

如果检查元素,即使我使用action="<?php echo $this->getFormAction(); ?>"

,表单操作值也会丢失

1 个答案:

答案 0 :(得分:0)

控制器可能存在PHP错误。 您应该尝试调试代码。 确保打开错误报告,暂时写入:

   error_reporting(E_ALL);
   ini_set('display_errors', 1);

在index.php文件的开头。