Finally got it working and here are my files.
Replace: catalog/view/theme/default/template/information/contact.tpl
Code: Select all
<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
<div class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
<?php } ?>
</div>
<h1><?php echo $heading_title; ?></h1>
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="contact">
<h2><?php echo $text_location; ?></h2>
<div class="contact-info">
<div class="content"><div class="left"><b><?php echo $text_address; ?></b><br />
<?php echo $store; ?><br />
<?php echo $address; ?></div>
<div class="right">
<?php if ($telephone) { ?>
<b><?php echo $text_telephone; ?></b><br />
<?php echo $telephone; ?><br />
<br />
<?php } ?>
<?php if ($fax) { ?>
<b><?php echo $text_fax; ?></b><br />
<?php echo $fax; ?>
<?php } ?>
</div>
</div>
</div>
<h2><?php echo $text_contact; ?></h2>
<!-- start contact mod by UKS //-->
<?php echo $text_required; ?>
<!-- end contact mod by UKS //-->
<div class="content">
<b><?php echo $entry_name; ?></b><br />
<input type="text" name="name" value="<?php echo $name; ?>" />
<br />
<?php if ($error_name) { ?>
<span class="error"><?php echo $error_name; ?></span>
<?php } ?>
<br />
<b><?php echo $entry_email; ?></b><br />
<input type="text" name="email" value="<?php echo $email; ?>" />
<br />
<?php if ($error_email) { ?>
<span class="error"><?php echo $error_email; ?></span>
<?php } ?>
<!-- start contact mod by UKSB //-->
<br />
<b><?php echo $entry_phone; ?></b><br />
<input type="text" name="phone" value="<?php echo $phone; ?>" />
<br />
<br />
<b><?php echo $entry_subject; ?></b><br />
<input type="text" name="subject" value="<?php echo $subject; ?>" style="width:200px;" />
<br />
<?php if ($error_subject) { ?>
<span class="error"><?php echo $error_subject; ?></span>
<?php } ?>
<!-- end contact mod by UKSB //-->
<br />
<b><?php echo $entry_enquiry; ?></b><br />
<textarea name="enquiry" cols="40" rows="10" style="width: 99%;"><?php echo $enquiry; ?></textarea>
<br />
<?php if ($error_enquiry) { ?>
<span class="error"><?php echo $error_enquiry; ?></span>
<?php } ?>
<br />
<b><?php echo $entry_captcha; ?></b><br />
<input type="text" name="captcha" value="<?php echo $captcha; ?>" />
<br />
<img src="index.php?route=information/contact/captcha" alt="" />
<?php if ($error_captcha) { ?>
<span class="error"><?php echo $error_captcha; ?></span>
<?php } ?>
</div>
<div class="buttons">
<div class="right"><a onclick="$('#contact').submit();" class="button"><span><?php echo $button_continue; ?></span></a></div>
</div>
</form>
<?php echo $content_bottom; ?></div>
<?php echo $footer; ?>
Code: Select all
<?php
class ControllerInformationContact extends Controller {
private $error = array();
public function index() {
$this->language->load('information/contact');
$this->document->setTitle($this->language->get('heading_title'));
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);
$mail->setSender($this->request->post['name']);
//start contact mod by UKSB
$mail->setSubject(sprintf($this->language->get('email_subject'), $this->request->post['subject']));
$emailmessage =
"Name: ".$this->request->post['name'].
"\nEmail: ".$this->request->post['email'].
($this->request->post['phone']!=''?"\nTelephone".$this->request->post['phone']:"").
"\n\n".$this->request->post['enquiry'].
"\n\n----------------------------------------\n\nSender's IP Address: ".$_SERVER['REMOTE_ADDR'];
$mail->setText(strip_tags(html_entity_decode($emailmessage, ENT_QUOTES, 'UTF-8')));
//end contact mod by UKSB
$mail->send();
$this->redirect($this->url->link('information/contact/success'));
}
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/contact'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_location'] = $this->language->get('text_location');
$this->data['text_contact'] = $this->language->get('text_contact');
$this->data['text_required'] = $this->language->get('text_required');
$this->data['text_address'] = $this->language->get('text_address');
$this->data['text_telephone'] = $this->language->get('text_telephone');
$this->data['text_fax'] = $this->language->get('text_fax');
$this->data['entry_name'] = $this->language->get('entry_name');
$this->data['entry_email'] = $this->language->get('entry_email');
//start contact mod by UKSB
$this->data['entry_phone'] = $this->language->get('entry_phone');
$this->data['entry_subject'] = $this->language->get('entry_subject');
//end contact mod by UKSB
$this->data['entry_enquiry'] = $this->language->get('entry_enquiry');
$this->data['entry_captcha'] = $this->language->get('entry_captcha');
if (isset($this->error['name'])) {
$this->data['error_name'] = $this->error['name'];
} else {
$this->data['error_name'] = '';
}
if (isset($this->error['email'])) {
$this->data['error_email'] = $this->error['email'];
} else {
$this->data['error_email'] = '';
}
//start contact mod by UKSB
if (isset($this->error['subject'])) {
$this->data['error_subject'] = $this->error['subject'];
} else {
$this->data['error_subject'] = '';
}
//end contact mod by UKSB
if (isset($this->error['enquiry'])) {
$this->data['error_enquiry'] = $this->error['enquiry'];
} else {
$this->data['error_enquiry'] = '';
}
if (isset($this->error['captcha'])) {
$this->data['error_captcha'] = $this->error['captcha'];
} else {
$this->data['error_captcha'] = '';
}
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['action'] = $this->url->link('information/contact');
$this->data['store'] = $this->config->get('config_name');
$this->data['address'] = nl2br($this->config->get('config_address'));
$this->data['telephone'] = $this->config->get('config_telephone');
$this->data['fax'] = $this->config->get('config_fax');
if (isset($this->request->post['name'])) {
$this->data['name'] = $this->request->post['name'];
} else {
$this->data['name'] = '';
}
if (isset($this->request->post['email'])) {
$this->data['email'] = $this->request->post['email'];
} else {
$this->data['email'] = '';
}
//start contact mod by UKSB
if (isset($this->request->post['phone'])) {
$this->data['phone'] = $this->request->post['phone'];
} else {
$this->data['phone'] = '';
}
if (isset($this->request->post['subject'])) {
$this->data['subject'] = $this->request->post['subject'];
} else {
$this->data['subject'] = '';
}
//end contact mod by UKSB
if (isset($this->request->post['enquiry'])) {
$this->data['enquiry'] = $this->request->post['enquiry'];
} else {
$this->data['enquiry'] = '';
}
if (isset($this->request->post['captcha'])) {
$this->data['captcha'] = $this->request->post['captcha'];
} else {
$this->data['captcha'] = '';
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/information/contact.tpl')) {
$this->template = $this->config->get('config_template') . '/template/information/contact.tpl';
} else {
$this->template = 'default/template/information/contact.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
public function success() {
$this->language->load('information/contact');
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/contact'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_message'] = $this->language->get('text_message');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['continue'] = $this->url->link('common/home');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/success.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/success.tpl';
} else {
$this->template = 'default/template/common/success.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
public function captcha() {
$this->load->library('captcha');
$captcha = new Captcha();
$this->session->data['captcha'] = $captcha->getCode();
$captcha->showImage();
}
private function validate() {
if ((strlen(utf8_decode($this->request->post['name'])) < 3)) {
$this->error['name'] = $this->language->get('error_name');
}
if (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}
//start contact mod by UKSB
if ((strlen(utf8_decode($this->request->post['subject'])) < 6)) {
$this->error['subject'] = $this->language->get('error_subject');
}
//end contact mod by UKSB
if ((strlen(utf8_decode($this->request->post['enquiry'])) < 10) || (strlen(utf8_decode($this->request->post['enquiry'])) > 3000)) {
$this->error['enquiry'] = $this->language->get('error_enquiry');
}
if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
$this->error['captcha'] = $this->language->get('error_captcha');
}
if (!$this->error) {
return true;
} else {
return false;
}
}
}
?>
Code: Select all
<?php
// Heading
$_['heading_title'] = 'Contact Us';
// Text
$_['text_location'] = 'Our Location';
$_['text_contact'] = 'Contact Form';
//start contact mod by UKSB
$_['text_required'] = '<p>Fields marked with <span class="required">*</span> are required!</p>';
//end contact mod by UKSB
$_['text_address'] = 'Address:';
$_['text_email'] = 'E-Mail:';
$_['text_telephone'] = 'Telephone:';
$_['text_fax'] = 'Fax:';
$_['text_message'] = '<p>Your enquiry has been successfully sent to the store owner!</p>';
//start contact mod by UKSB
// Entry Fields
$_['entry_name'] = 'Name:<span class="required">*</span>';
$_['entry_email'] = 'E-Mail Address:<span class="required">*</span>';
$_['entry_phone'] = 'Telephone:';
$_['entry_subject'] = 'Subject:<span class="required">*</span>';
$_['entry_enquiry'] = 'Enquiry:<span class="required">*</span>';
$_['entry_captcha'] = 'Enter the code in the box below:<span class="required">*</span>';
//end contact mod by UKSB
// Email
$_['email_subject'] = 'Website Enquiry: %s';
// Errors
$_['error_name'] = 'Name must contain more than 2 characters!';
$_['error_email'] = 'E-Mail Address does not appear to be valid!';
//start contact mod by UKSB
$_['error_subject'] = 'Subject must contain more than 5 characters!';
//end contact mod by UKSB
$_['error_enquiry'] = 'Enquiry must be between 10 and 3000 characters!';
$_['error_captcha'] = 'Verification code does not match the image!';
?>
- Added - Required field indicator
- Changed - First name to Name
- Added - Telephone field (not a required field)
- Added Message Subject field
- Edited the subject seen on the email from 'Enquiry Name' to 'Website Enquiry: Subject'
- Added Sender's IP Address
For those of you who use vQmod