如何为默认的opencart创建副本与其他字段联系我们表格 [英] How to create duplicate for default opencart contact us form with additional fields

查看:66
本文介绍了如何为默认的opencart创建副本与其他字段联系我们表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的opencart模板中,我需要创建一个类似于联系表单的表单,其中包含姓名,电子邮件和手机号码.我已经在我的联系我们页面中使用了默认的联系我们表单.我需要创建这个新表单另一页的表单.是否有免费的扩展名?否则我们如何实现自己的表单?

In my opencart template i need to create a form which is similar to contact form with the fields Name,Email and Mobile number.I have already used the default contact us form in my contact us page.I need to create this new form for another page.Is there any free extension available?Or else how can we implement our own form?

推荐答案

我不会推荐任何扩展名(这不是这样做的地方),但是我可以告诉您一些与联系人重复的步骤.

I am not going to recommend any extension (this is not the place to do so) but i can tell you some steps duplicate the contact from.

首先,您需要在各自的目录中复制三个文件

First you need to duplicate three files in their respective directories

  1. catalog\language\english\information\contact.php
  2. catalog\view\theme\default\template\information\contact.tpl
  3. catalog\controller\information\contact.php
  1. catalog\language\english\information\contact.php
  2. catalog\view\theme\default\template\information\contact.tpl
  3. catalog\controller\information\contact.php

并将其命名为form.phpform.tplform.php

此后的所有更改将仅在这些文件上执行

All changes after this point will be performed on these files only

现在将您的控制器类名称更改为ControllerInformationForm 除此之外,您还必须在控制器文件中编辑一些内容,例如将contact.tpl更改为form.tpl,使用$this->language->load('information/form');

now change you controller class name to ControllerInformationForm other than this you will have to edit several things in controller file like change contact.tpl to form.tpl , load correct language file using $this->language->load('information/form');

对控制器文件进行必要的更改后,可以使用website.com/index.php?route=information/form

after making necessary changes to controller file, your new form can be accessed using website.com/index.php?route=information/form

现在为其他字段添加一个现有字段,如name,并使用新字段在这3个文件中完成name的所有操作

now for additional field take one existing field like name and do all things which are done for name in these 3 files with your new field

注意不要为您执行$mail->setSender($this->request->post['name']);新字段(与其他字段不同)

Note don't do $mail->setSender($this->request->post['name']); for you new field its different

现在在tpl中让您在tpl中有这样的新字段

now lets in tpl you have new field in tpl like this

<input type="text" name="city" value="<?php echo $city; ?>" />

然后在控制器中更改以下行

then in your controller change following line

$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));

$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'] . " " . $this->request->post['city'], ENT_QUOTES, 'UTF-8')));

免责声明:这不是一整套说明,但这足以让您开始并提出更好的问题,如果您遇到任何问题

Disclaimer : This not a full set of instruction but this is enough for you to start and to ask better question if you face any problem

这篇关于如何为默认的opencart创建副本与其他字段联系我们表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆