เพิ่ม field ที่ต้องการในหน้า contact-form.phpทำ css ไม่เป็นเลย
เห็นของตัวเองแล้ว

-----------
ถ้าอยากเพิ่ม option ใน contact-form.php นี่ต้องไปแก้ตรงไหนครับ

ต้องแก้ไข 3 ไฟล์ครับ คือ contact-form.php , themes/ธีมที่ใช้/contact-form.tpl, mails/ภาษา/contact.html
ให้แก้ไขที่ไฟล์ themes/ธีมที่ใช้/contact-form.tpl ก่อนครับ โดยการเพิ่ม input ที่ต้องการใช้งานเข้าไป หลังจากส่วนนี้ครับ
<form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std">
<fieldset>
<h3>{l s='Send a message'}</h3>
<p class="select">
<label for="id_contact">{l s='Subject'}</label>
<select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')">
<option value="0">{l s='-- Choose --'}</option>
{foreach from=$contacts item=contact}
<option value="{$contact.id_contact|intval}" {if isset($smarty.post.id_contact) && $smarty.post.id_contact == $contact.id_contact}selected="selected"{/if}>{$contact.name|escape:'htmlall':'UTF-8'}</option>
{/foreach}
</select>
</p>
<p id="desc_contact0" class="desc_contact"> </p>
{foreach from=$contacts item=contact}
<p id="desc_contact{$contact.id_contact|intval}" class="desc_contact" style="display:none;">
<label> </label>{$contact.description|escape:'htmlall':'UTF-8'}</p>
{/foreach}
ในไฟล์ที่ให้ดาวโหลดผมจะมีตัวอย่าง แต่จะ comment ส่วนนั้นๆไว้อยู่ครับ ลักษณะการเพิ่ม input หรือ field ที่ต้องการ ควรอยู่ในรูปแบบนี้ครับ อยากเพิ่ม field ไหนบ้างก็เพิ่มตามรูปแบบที่ให้ไว้ครับ
<p class="required text">
<label for="name">{l s='First Name'}</label>
<input type="text" id="name" name="name" value="{if isset($smarty.post.name)}{$smarty.post.name|escape:'htmlall'|stripslashes}{/if}" /> <sup>*</sup>
</p>
-
สีแดง คือ required field
-
สีม่วง คือ ตัวแปรของ field นั้นๆ
-
สีน้ำเงิน คือ ข้อความกำกับ input Textbox
====================================
เมื่อเพิ่ม field จนพอใจแล้ว ต่อมาก็ไปแก้ไขที่ไฟล์ contact-form.php โดยเพิ่มตัวแปรในการรับค่าจาก form เพื่อใช้ในการส่งอีเมลล์ จะมีการรับตัวแปร 2 แบบ คือ แบบ required field กับ ไม่ required field
แบบ required field คือ จะตรวจสอบค่าที่ส่งมาจาก form ว่าต้องไม่เป็นค่าว่าง
แบบไม่ required field คือ ค่าที่ส่งมาจะเป็นค่าว่างหรือไม่ก็ได้
รูปแบบโค้ด required field
elseif (!($name = nl2br2(Tools::getValue('name'))))
$errors[] = Tools::displayError('First Name cannot be blank');
รูปแบบโค้ดที่ไม่ใช้ required field
$name = nl2br2(Tools::getValue('name'));
-
สีม่วง คือ ตัวแปรจาก field ต่างๆ
-
สีน้ำเงิน คือ ข้อความใช้สำหรับแสดง error
ต่อมา จัดการตัวแปรที่จะส่งไปที่ Template mail ให้ใส่ตัวแปร field ต่างๆ เข้าไปใน array ภายใน
if ( Mail :: Send ( intval ( $cookie -> id_lang ), 'contact' , 'Message from contact form' , array( '{email}' => $_POST[ 'from' ] , '{message}' => stripslashes ( $message ), '{name}' => stripslashes ( $name ), '{lastname}' => stripslashes ( $lastname ), '{address}' => stripslashes ( $address ), '{city}' => stripslashes ( $city ), '{postalcode}' => stripslashes ( $postalcode ), '{Country}' => stripslashes ( $Country ), '{telephone}' => $_POST[ 'telephone' ] ) , $contact -> email ))
สังเกตรูปแบบนะครับ รูปแบบจะเป็นแบบนี้ '{ตัวแปรที่ใช้ในเมล}' => stripslashes($ตัวแปรที่รับค่าจากform)
====================================
แก้ไข Template mail ของ mails/ภาษา/contact.html เพิ่ม field ที่ต้องการแสดงในเมลล์
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd
">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Message from {shop_name}</title>
</head>
<body>
<table style="font-family:Verdana,sans-serif; font-size:11px; color:#374953; width: 550px;">
<tr>
<td align="left">
<a href="{shop_url}" title="{shop_name}"><img alt="{shop_name}" src="{shop_logo}" style="border:none;" ></a>
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="left" style="background-color:#DB3484; color:#FFF; font-size: 12px; font-weight:bold; padding: 0.5em 1em;">Message from your shop {shop_name}</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="left">
Name: {name}
<br><br>
Last Name: {lastname}
<br><br>
.
.
.
E-mail address: <a href="mailto:{email}"><b>{email}</b></a>
<br><br>
Message: {message}
</td>
</tr>
<tr><td> </td></tr>
<tr>
<td align="center" style="font-size:10px; border-top: 1px solid #D9DADE;">
<a href="{shop_url}" style="color:#DB3484; font-weight:bold; text-decoration:none;">{shop_name}</a> powered with <a href="http://www.prestashop.com/
" style="text-decoration:none; color:#374953;">PrestaShop™</a>
</td>
</tr>
</table>
</body>
</html>
-
สีแดง คือ ช่วงที่ใส่ field ที่ต้องการ
-
สีม่วง คือ ค่าตัวแปร field ต่างๆ
ไฟล์ตัวอย่าง
Download
- ทำการ Back up ไฟล์เก่าไว้ด้วยนะครับ ไฟล์ตัวอย่างจะ required field 1 field คือ ช่อง Name
- นำไฟล์ใช้งานไปไว้ยังโฟลเดอร์ที่ถูกต้อง