PDA

View Full Version : Contact Us (Related to)



Oslo
January 25, 2013, 02:07 PM
Hello Flynax,

Is there anyway to add a field (Related to) in Contact us page, like as flynax contact us page http://www.flynax.com/contact-us.html

We have 3 type contact, we wanna the users who wanna contact use, give a option to select which type contact. Like as flynax have 6 Related to contact.

1. Contact (Support) to email support@my-domain.com
2. Contact (In Swedish Language) to email svensk@my-domain.com
3. Contact (In Norway Language) to email norsk@my-domain.com

341

Milea Ionut
January 25, 2013, 02:09 PM
This is a very good option!

Peter Jonsson
January 25, 2013, 02:46 PM
+1 on this

Morgan Bohman
January 25, 2013, 05:24 PM
2nd this as well

Mike
January 26, 2013, 06:03 AM
Ok :)

1. includes/controllers/contact_us.ing.php



/* 1st thing */
$deparments["deparment1"] = array("name" => $lang['deparment1_name'], "email" => "deparment1@site.com") ;
$deparments["deparment2"] = array("name" => $lang['deparment2_name'], "email" => "deparment2@site.com") ;
$rlSmarty -> assign_by_ref( 'deparments', $deparments );
/* 1st thing end */

if ( $_POST['action'] == 'contact_us' )
{
$errors = array();

...
$mail_tpl = $rlMail -> getEmailTemplate( 'contact_us' );
$mail_tpl['body'] = str_replace( array('{name}', '{message}'), array($your_name, $message), $mail_tpl['body'] );
$mail_tpl['subject'] = str_replace( '{name}', $your_name, $mail_tpl['subject'] );

$rlMail -> send( $mail_tpl, $deparments[$_POST['dertment']]['email'], null, $your_email, $your_name ); //2nd thing

....}


2. templates/template/tpl/controllers/contact_us.tpl




<tr>
<td class="name">{$lang.your_email} <span class="red">*</span></td>
<td class="field">
<input type="text" name="your_email" maxlength="100" value="{if $smarty.post.your_email}{$smarty.post.your_email}{ else}{$account_info.Mail}{/if}" />
</td>
</tr>
<!-- 3rd thing -->
<tr>
<td class="name">{$lang.contact_departments} <span class="red">*</span></td>
<td class="field">
<select name="department" >
{foreach from=$deparments key="key" item="department"}
<option value="{$key}">{$department.name}</option>
{/foreach}
</select>
</td>
</tr>
<!-- 3rd thing end -->

{rlHook name='contactFields'}




also you have to add 3 phrases through the languages manager in Admin Panel:

contact_departments - name of deparments fields in the form
department1_name, department2_name

Oslo
January 26, 2013, 12:57 PM
Thanks Mike,

But when I add the 1st thing anywhere in contact_us.inc.php gives error HTTP 500 Internal server error.

2st thing and 3rd thing added without any problem, and added keys contact_departments, department1_name, department2_name into language in admin panel.

So, the 1st thing line where should we add which line?

ATServiceSRL
January 26, 2013, 02:43 PM
More beautyful to insert different departments and relative email directly in the admin panel ? :-)

Oslo
January 29, 2013, 12:04 PM
Is there anyone who did it?

Fulvio Di stefano
April 29, 2013, 04:12 PM
No way to add easily text in the contact us page ?? Text that should be modified by the owner without coding...

Mike
April 30, 2013, 09:30 AM
No way to add easily text in the contact us page ?? Text that should be modified by the owner without coding...

Please clarify what is the text for ??
you can edit any text from the Admin Panel>>Languages,

ALso im sorry for delay with replies to others, - please let me know if you have problems with the customization above. I remember it worked smoothly for me.

Mike
April 30, 2013, 09:31 AM
No way to add easily text in the contact us page ?? Text that should be modified by the owner without coding...

Please clarify what is the text for ??
you can edit any text from the Admin Panel>>Languages,

ALso im sorry for delay with replies to others, - please let me know if you have problems with the customization above. I remember it worked smoothly for me.

Fulvio Di stefano
April 30, 2013, 09:33 AM
In the contact us page i would like to add any kind of text above the form. I dont know, the adress, business hours, a google map....in a way that admin can edit it easily !
Actually i have created another page and created a link to this one to use the form, but everything on one page would be more logical!

Oslo
May 1, 2013, 09:54 AM
Hello Mike,

2en and 3rd are ok, but when I add the following code into includes/controllers/contact_us.ing.php


/* 1st thing */
$deparments["deparment1"] => array("Name" => $lang['deparment1_name'], "email" => "deparment1@site.com") ;
$deparments["deparment2"] => array("Name" => $lang['deparment2_name'], "email" => "deparment2@site.com") ;
$rlSmarty -> assign_by_ref( 'deparments', $deparments );
/* 1st thing end */

gives the following error.

Parse error: syntax error, unexpected T_DOUBLE_ARROW in /var/www/my.domain/httpdocs/includes/controllers/contact_us.inc.php on line 4

the line 4 it's


$deparments["deparment1"] => array("Name" => $lang['deparment1_name'], "email" => "support@mysite.com") ;

here is the code from line 1 into line 11


<?php

/* 1st thing */
$deparments["deparment1"] => array("Name" => $lang['department1_name'], "email" => "support@mysite.com") ;
$deparments["deparment2"] => array("Name" => $lang['department2_name'], "email" => "sale@mysite.com") ;
$rlSmarty -> assign_by_ref( 'deparments', $deparments );
/* 1st thing end */

if ( $_POST['action'] == 'contact_us' )
{
$errors = array();

is that correct?

and in 1st thing you typed $deparments["deparment1"] are this correct? or must be department?

Mike
May 17, 2013, 09:19 AM
Sorry for delay with replies and the wrong code,
to fix parse error please correct code as below



/* 1st thing */
$deparments["deparment1"] = array("name" => $lang['department1_name'], "email" => "support@mysite.com") ;
$deparments["deparment2"] => array("name" => $lang['department2_name'], "email" => "sale@mysite.com") ;
$rlSmarty -> assign_by_ref( 'deparments', $deparments );
/* 1st thing end */

if ( $_POST['action'] == 'contact_us' )
{
$errors = array();





and in 1st thing you typed $deparments["deparment1"] are this correct? or must be department?

yes its correct, if you want you can use another key for your deparments, deparment1 is just sample for deparment key

Oslo
May 17, 2013, 05:45 PM
Now, doesn't gives any error.

But in contact page, the select option is Empty, I already added the following phrases department1_name, department2_name into the language in admin panel, but shows as empty on contact page.

In admin: 511

In contact page: 512

the code below are placed in include tpl/controllers/contact_us.tpl


<tr>
<td class="name">{$lang.your_email} <span class="red">*</span></td>
<td class="field">
<input type="text" name="your_email" maxlength="100" value="{if $smarty.post.your_email}{$smarty.post.your_email}{ else}{$account_info.Mail}{/if}" />
</td>
</tr>
<!-- 3rd thing -->
<tr>
<td class="name">{$lang.contact_departments} <span class="red">*</span></td>
<td class="field">
<select name="department" >
{foreach from=$deparments key="key" item="department"}
<option value="{$key}">{$deparment.name}</option>
{/foreach}
</select>
</td>
</tr>
<!-- 3rd thing end -->

{rlHook name='contactFields'}

Mike
May 20, 2013, 03:41 AM
:( another mistake i see now in the php code (Name --change to--> name)



/* 1st thing */
$deparments["deparment1"] = array("name" => $lang['department1_name'], "email" => "support@mysite.com") ;
$deparments["deparment2"] => array("name" => $lang['department2_name'], "email" => "sale@mysite.com") ;
$rlSmarty -> assign_by_ref( 'deparments', $deparments );
/* 1st thing end */

if ( $_POST['action'] == 'contact_us' )
{
$errors = array();



sorry for inconveniences, let me know in case it still have problems

Oslo
May 20, 2013, 08:40 AM
still are same issues.

here is all my codes.

File: tpl/controllers/contact_us.tpl


/* 1st thing */
$deparments["deparment1"] = array("name" => $lang['department1_name'], "email" => "support@mysite.com") ;
$deparments["deparment2"] = array("name" => $lang['department2_name'], "email" => "sale@mysite.com") ;
$rlSmarty -> assign_by_ref( 'deparments', $deparments );
/* 1st thing end */

if ( $_POST['action'] == 'contact_us' )
{
$errors = array();

File: template/tpl/controllers/contact_us.tpl


<tr>
<td class="name">{$lang.your_email} <span class="red">*</span></td>
<td class="field">
<input type="text" name="your_email" maxlength="100" value="{if $smarty.post.your_email}{$smarty.post.your_email}{ else}{$account_info.Mail}{/if}" />
</td>
</tr>
<!-- 3rd thing -->
<tr>
<td class="name">{$lang.contact_departments} <span class="red">*</span></td>
<td class="field">
<select name="department" >
{foreach from=$deparments key="key" item="department"}
<option value="{$key}">{$deparment.name}</option>
{/foreach}
</select>
</td>
</tr>
<!-- 3rd thing end -->

{rlHook name='contactFields'}

I did everything as you said, but still shows as empty in select option.

Mike
May 27, 2013, 08:28 AM
Sorry, there is misspelling again (. we see what happens when you do not test code =) Problem was in {$department.name} variable it was {$deparment.name}

Here is the corrected code.




<tr>
<td class="name">{$lang.your_email} <span class="red">*</span></td>
<td class="field">
<input type="text" name="your_email" maxlength="100" value="{if $smarty.post.your_email}{$smarty.post.your_email}{ else}{$account_info.Mail}{/if}" />
</td>
</tr>
<!-- 3rd thing -->
<tr>
<td class="name">{$lang.contact_departments} <span class="red">*</span></td>
<td class="field">
<select name="department" >
{foreach from=$deparments key="key" item="department"}
<option value="{$key}">{$department.name}</option>
{/foreach}
</select>
</td>
</tr>
<!-- 3rd thing end -->

{rlHook name='contactFields'}

Oslo
May 27, 2013, 11:15 AM
Hello Mike F.

Now everything is looking fine, only one thing it doesn't working as will.


/* 1st thing */
$deparments["deparment1"] = array("name" => $lang['department1_name'], "email" => "info@domian.com") ;
$deparments["deparment2"] = array("name" => $lang['department2_name'], "email" => "help@domian.com") ;
$rlSmarty -> assign_by_ref( 'deparments', $deparments );
/* 1st thing end */

If I choose any one in Contact forum department1 or department2, I receive the email to Site main email of my website (admin@domian.com) not to department1 ===> info@domain.com.

How we can fix it.

Mike
May 27, 2013, 11:27 AM
I think the line is not changed as i described in first message ?



$rlMail -> send( $mail_tpl, $deparments[$_POST['department']]['email'], null, $your_email, $your_name );

Oslo
May 27, 2013, 06:34 PM
Hello Mike F.

Now I changed it and working 100%.

Thanks again, I appreciate.

huyhnh12
May 28, 2013, 02:59 PM
This worked for me, thank you.

How do I add additional text fields, say, a dropdown for a browser list?

Like a Help form with

username:
email:
browser (dropdown to options like Internet Explorer, Firefox, etc)

etc?


Related, it would be nice if we had the ability to edit and add fields from the admin panel, like a Gravity Form plugin.