Latest articles
Latest articles of category




ContactUs.tpl


ContactUs.tpl is the tpl file which includes the contact form of the website. It can be found on http://yourdomain.com/lang/contactUs.html. It is not a static page, the .html extension is automatically generated via mod_rewrite and .htaccess. If you want to give a different name feel free to edit .htaccess. This has been done for SEO (Search Engine optimization).

All fields in the form with * are required to be filled. When the form is submitted a message appeared which informs you that the data has been sent. Then a redirection to the main page is done in 4 seconds. If you need to change that message search inside the contactUs.tpl for the text:

{t}Thanks for your comments, your message sent successfully.{/t}
{t}We will try to reply as soon as possible.{/t}
<p>{t}You will be redirected to the main page in 4 seconds.{/t}

and make your adjustments. After you've made any changes, you will need to use Poedit or any other Gettext compatible editor to parse the new strings, in order to translate them to any other language that you might have in your web site. Read this article to learn how to use Poedit with Guru CMS.

How to add your own text to contact us form
If you want to display let's say your company's details in the beginning of the form, just edit contactUs.tpl and add any text that you like before the <form> element.
If you want also to translate this to multiple languages you will need to put it inside the
 
{t}{/t}
tags and then use poedit to translate the text.

An example of contactUS.tpl is shown below:

contactUs.tpl
 
<form method="post" enctype="multipart/form-data">
  <table width="70%">
    <tr>
      <td>{t}Full Name{/t}*</td>
        <td><input name="sender_name" type="text" class="textFormElement" value="" size="41"/></td>
      </tr>
    <tr>
      <td>{t}E-mail address{/t} *</td>
        <td><input name="sender_email" type="text" class="textFormElement" value="" size="41"/></td>
      <strong style="color: red;">{$invalid_email}</strong> </tr>
    <tr>
      <td >{t}Title{/t} *</td>
        <td><input name="comment_title" type="text" class="textFormElement" value="" size="41" /></td>
      </tr>
    <tr>
      <td >{t}Comment{/t} *</td>
        <td>  <textarea name="comment_body" rows=10 cols=47 class="textFormElement"></textarea></td>
    </tr>
    <tr>
      <td>{t}Security Code{/t}: *</td>
    <td><input id="code" name="code" type="text" /></td></tr>
    <tr><td colspan="2">
        {captcha name="captcha" length=6} </td>
    </tr>
    <tr>
      <td colspan="2"><br />
      <input type="submit" name="submit_contact" value="{t}Submit{/t}" class="formButtonSubmit" />
            <a href="{$smarty.const.WEBSITE_ROOT}/{$smarty.session.session_lang}/index.php">
              <input type="button" value="{t}Cancel{/t}" class="formButtonSubmit" />
            </a></td></tr>
    {if isset($smarty.post.submit_contact)}
    <strong style="color: red;">{$invalid_email} {$code_error}</strong><br />
    {if $name=='' || $title=='' || $email=='' || $body=='' || $code==''} <strong style="color: red;">{t}{$not_enough_info}{/t}</strong> {/if}

    {if $sent}
     <meta http-equiv="refresh" content="4;URL={$smarty.const.WEBSITE_ROOT}/{$smarty.session.session_lang}/index.php" />
              <strong style="color: red;"> {t}Thanks for your comments, your message sent successfully.{/t}
                {t}We will try to reply as soon as possible.{/t}
               <p> {t}You will be redirected to the main page in 4 seconds.{/t} </p></strong>
              <p></p>

    {/if}
    {/if}
  </table>
</form>

When you submit the form successfully you will not receive any error at all. If you've got an error then probably you have wrong settings under includes/settings.php on Swift mailer section. Double check that the settings you have there are valid.

 

 

Posted on: 23/03/2011