Could you help me to add a field in rapid contact

More
11 years 9 months ago #27159 by susanagarduno1
Hello again,

Could you tell me how to add a field in rapid contact form?

Regards,

Susana

Please Log in to join the conversation.

More
11 years 9 months ago #27167 by ivan.milic
There is no option to add custom field in rapid contact module

Please Log in to join the conversation.

More
11 years 9 months ago #27310 by susanagarduno1
Hello again, sorry if I'm very insistent. But my boss ask it to me.

So I modified the php code as following:


?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

//Email Parameters
$recipient = $params->get('email_recipient', '');
$fromName = @$params->get('from_name', 'Rapid Contact');
$fromEmail = @$params->get('from_email', 'rapid_contact@yoursite.com');

// Text Parameters
$myNameLabel = $params->get('name_label', 'Nombre:');
$myEmailLabel = $params->get('email_label', 'Email:');
$mySubjectLabel = $params->get('subject_label', 'Subject:');
$myMessageLabel = $params->get('message_label', 'Message:');
$buttonText = $params->get('button_text', 'Send Message');
$pageText = $params->get('page_text', 'Thank you for your contact.');
$errorText = $params->get('error_text', 'Your message could not be sent. Please try again.');
$noEmail = $params->get('no_email', 'Please write your email');
$invalidEmail = $params->get('invalid_email', 'Please write a valid email');
$wrongantispamanswer = $params->get('wrong_antispam', 'Wrong anti-spam answer');
$pre_text = $params->get('pre_text', '');

// Size and Color Parameters
$thanksTextColor = $params->get('thank_text_color', '#FF0000');
$error_text_color = $params->get('error_text_color', '#FF0000');
$nameWidth = $params->get('name_width', '20');
$emailWidth = $params->get('email_width', '15');
$subjectWidth = $params->get('subject_width', '15');
$messageWidth = $params->get('message_width', '13');
$buttonWidth = $params->get('button_width', '100');
$label_pos = $params->get('label_pos', '0');
$addcss = $params->get('addcss', 'div.rapid_contact tr, div.rapid_contact td { border: none; padding: 3px; }');

// URL Parameters
$exact_url = $params->get('exact_url', true);
$disable_https = $params->get('disable_https', true);
$fixed_url = $params->get('fixed_url', true);
$myFixedURL = $params->get('fixed_url_address', '');

// Anti-spam Parameters
$enable_anti_spam = $params->get('enable_anti_spam', true);
$myAntiSpamQuestion = $params->get('anti_spam_q', 'How many eyes has a typical person?');
$myAntiSpamAnswer = $params->get('anti_spam_a', '2');
$anti_spam_position = $params->get('anti_spam_position', 0);

// Module Class Suffix Parameter
$mod_class_suffix = $params->get('moduleclass_sfx', '');


if ($fixed_url) {
$url = $myFixedURL;
}
else {
if (!$exact_url) {
$url = JURI::current();
}
else {
if (!$disable_https) {
$url = (!empty($_SERVER)) ? "https://".$_SERVER.$_SERVER : "http://".$_SERVER.$_SERVER;
}
else {
$url = "http://".$_SERVER.$_SERVER;
}
}
}

$url = htmlentities($url, ENT_COMPAT, "UTF-8");

$myError = '';
$CORRECT_NAME = '';
$CORRECT_ANTISPAM_ANSWER = '';
$CORRECT_EMAIL = '';
$CORRECT_SUBJECT = '';
$CORRECT_MESSAGE = '';

if (isset($_POST["rp_email"])) {
$CORRECT_SUBJECT = htmlentities($_POST["rp_subject"], ENT_COMPAT, "UTF-8");
$CORRECT_MESSAGE = htmlentities($_POST["rp_message"], ENT_COMPAT, "UTF-8");
// check anti-spam
if ($enable_anti_spam) {
if ($_POST["rp_anti_spam_answer"] != $myAntiSpamAnswer) {
$myError = '<span style="color: ' . $error_text_color . ';">' . $wrongantispamanswer . '</span>';
}
else {
$CORRECT_ANTISPAM_ANSWER = htmlentities($_POST["rp_anti_spam_answer"], ENT_COMPAT, "UTF-8");
}
}
// check email
if ($_POST["rp_email"] === "") {
$myError = '<span style="color: ' . $error_text_color . ';">' . $noEmail . '</span>';
}
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/", strtolower($_POST["rp_email"]))) {
$myError = '<span style="color: ' . $error_text_color . ';">' . $invalidEmail . '</span>';
}
else {
$CORRECT_EMAIL = htmlentities($_POST["rp_email"], ENT_COMPAT, "UTF-8");
}

if ($myError == '') {
$mySubject = $_POST["rp_subject"];
$myMessage = 'You received a message from '. $_POST["rp_email"] ."\n\n". $_POST["rp_message"];

$mailSender = &JFactory::getMailer();
$mailSender->addRecipient($recipient);

$mailSender->setSender(array($fromEmail,$fromName));
$mailSender->addReplyTo(array( $_POST["rp_email"], '' ));

$mailSender->setSubject($mySubject);
$mailSender->setBody($myMessage);

if ($mailSender->Send() !== true) {
$myReplacement = '<span style="color: ' . $error_text_color . ';">' . $errorText . '</span>';
print $myReplacement;
return true;
}
else {
$myReplacement = '<span style="color: '.$thanksTextColor.';">' . $pageText . '</span>';
print $myReplacement;
return true;
}

}
} // end if posted

// check recipient
if ($recipient === "") {
$myReplacement = '<span style="color: ' . $error_text_color . ';">No recipient specified</span>';
print $myReplacement;
return true;
}

print '';
print '<div class="rapid_contact ' . $mod_class_suffix . '"><form action="' . $url . '" method="post">' . "\n" .
'<div class="rapid_contact intro_text ' . $mod_class_suffix . '">'.$pre_text.'</div>' . "\n";

if ($myError != '') {
print $myError;
}

$separator = '</td><td>';
$emptycell = '<td></td>';
if ($label_pos == '1') {
$separator = '<br/>';
$emptycell = '';
}

print '<table>';

// print anti-spam
if ($enable_anti_spam) {
if ($anti_spam_position == 0) {
print '<tr><td colspan="2">' . $myAntiSpamQuestion . '</td></tr><tr>'.$emptycell.'<td><input class="rapid_contact inputbox ' . $mod_class_suffix . '" type="text" name="rp_anti_spam_answer" size="' . $emailWidth . '" value="'.$CORRECT_ANTISPAM_ANSWER.'"/></td></tr>' . "\n";
}
}
// print name input
print '<tr><td>' . $myNameLabel . $separator . '<input class="rapid_contact inputbox ' . $mod_class_suffix . '" type="text" name="rp_name" size="' . $nameWidth . '" value="'.$CORRECT_NAME.'"/></td></tr>' . "\n";
// print email input
print '<tr><td>' . $myEmailLabel . $separator . '<input class="rapid_contact inputbox ' . $mod_class_suffix . '" type="text" name="rp_email" size="' . $emailWidth . '" value="'.$CORRECT_EMAIL.'"/></td></tr>' . "\n";
// print subject input
print '<tr><td>' . $mySubjectLabel . $separator . '<input class="rapid_contact inputbox ' . $mod_class_suffix . '" type="text" name="rp_subject" size="' . $subjectWidth . '" value="'.$CORRECT_SUBJECT.'"/></td></tr>' . "\n";
// print message input
print '<tr><td valign="top">' . $myMessageLabel . $separator . '<textarea class="rapid_contact textarea ' . $mod_class_suffix . '" name="rp_message" cols="' . $messageWidth . '" rows="4">'.$CORRECT_MESSAGE.'</textarea></td></tr>' . "\n";

//print anti-spam
if ($enable_anti_spam) {
if ($anti_spam_position == 1) {
print '<tr><td>' . $myAntiSpamQuestion . $separator .'<input class="rapid_contact inputbox ' . $mod_class_suffix . '" type="text" name="rp_anti_spam_answer" size="' . $emailWidth . '" value="'.$CORRECT_ANTISPAM_ANSWER.'"/></td></tr>' . "\n";
}
}
// print button
print '<tr><td colspan="2"><input class="rapid_contact button ' . $mod_class_suffix . '" type="submit" value="' . $buttonText . '" style="width: ' . $buttonWidth . '%"/></td></tr></table></form></div>' . "\n";
return true;


And then I modified xml as following:

<?xml version="1.0" encoding="utf-8"?>
<extension version="1.6.0" client="site" type="module" method="upgrade">
<name>Rapid Contact</name>
<author>Christopher Mavros</author>
<creationDate>March 2011</creationDate>
<copyright>Copyright (C) 2009-2011 Christopher Mavros. All rights reserved.</copyright>
<license>GNU General Public License</license>
<authorEmail>mavrosxristoforos@gmail.com
<authorUrl> www.mavrosxristoforos.com/
<version>1.2</version>
<description>Rapid Contact. Lightweight, fast and easy, configuring a contact form, was never a pleasure before.</description>
<files>
<filename module="mod_rapid_contact">mod_rapid_contact.php</filename>
</files>
<config><fields name="params"><fieldset name="basic">
<field name="spacert1" type="spacer" class="text" label="&lt;strong&gt;Email Parameters&lt;/strong&gt;"/>
<field name="email_recipient"
type="text"
default="email@email.com"
label="Email Recipient"
description="The recipient of the contact mail." />
<field name="from_name"
type="text"
default="Rapid Contact"
label="Mail From Name"
description="The name of the message's sender" />
<field name="from_email"
type="text"
default="rapid_contact@yoursite.com"
label="Mail From Email"
description="The email of the message's sender" />

<field name="spacer1" type="spacer" hr="true"/>
<field name="spacert2" type="spacer" class="text" label="&lt;strong&gt;Text Parameters&lt;/strong&gt;"/>
<field name="name_label"
type="text"
default="Nombre:"
label="Name Label"
description="The label next to the email input." />
<field name="email_label"
type="text"
default="Email:"
label="Email Label"
description="The label next to the email input." />
<field name="subject_label"
type="text"
default="Subject:"
label="Subject Label"
description="The label next to the subject input." />
<field name="message_label"
type="text"
default="Message:"
label="Message Label"
description="The label next to the message text area." />
<field name="button_text"
type="text"
default="Send Message"
label="Button Text"
description="The text on the send button" />
<field name="page_text"
type="text"
default="Thank you for your contact."
label="Thank you text"
description="The text displayed to the user when he sends a message" />
<field name="error_text"
type="text"
default="Your message could not be sent. Please try again."
label="Error page text"
description="The text displayed to the user when the message fails to be sent" />
<field name="no_email"
type="text"
default="Please write your email"
label="No Email Error Message"
description="The error message when the user does not write an email" />
<field name="invalid_email"
type="text"
default="Please write a valid email"
label="Invalid Email Error Message"
description="The error message when the user writes an invalid email" />
<field name="wrong_antispam"
type="text"
default="Wrong Anti-Spam Answer"
label="Wrong Anti-Spam Text"
description="The text to show when the user fails to pass the anti-spam check"/>
<field name="pre_text"
type="text"
default=""
label="Small Intro Text"
description="A small text shown before (above) the message form. HTML is welcome!" />

<field name="spacer2" type="spacer" hr="true"/>
<field name="spacert3" type="spacer" class="text" label="&lt;strong&gt;Size and Color Parameters&lt;/strong&gt;"/>
<field name="thank_text_color"
type="text"
default="#FF0000"
label="Text Color"
description="The color of the Thank you text." />
<field name="error_text_color"
type="text"
default="#FF0000"
label="Error Text Color"
description="The color of the Error text." />
<field name="email_width"
type="text"
default="15"
label="Email Width"
description="Width in letters of the email input" />
<field name="subject_width"
type="text"
default="15"
label="Subject Width"
description="Width in letters of the subject input" />
<field name="message_width"
type="text"
default="13"
label="Message Width"
description="Width in columns of the message textarea" />
<field name="button_width"
type="text"
default="100"
label="Button Width"
description="Width in percent of the send button" />
<field name="label_pos"
type="radio" default="0"
label="Label Position"
description="The position of the labels relative to the inputboxes">
<option value="0">Left</option>
<option value="1">Top</option>
</field>
<field name="addcss"
type="text"
default="div.rapid_contact tr, div.rapid_contact td { border: none; padding: 3px; }"
label="Custom CSS"
description="Custom CSS for the form." />

<field name="spacer3" type="spacer" hr="true"/>
<field name="spacert4" type="spacer" class="text" label="&lt;strong&gt;URL Parameters&lt;/strong&gt;"/>
<field name="exact_url"
type="radio"
default="1"
label="Exact URL"
description="This is an advanced option about the url retrieval way. If your site is http and your server/host supports https this should be No.">
<option value="0">No</option>
<option value="1">Yes</option>
</field>
<field name="disable_https"
type="radio"
default="1"
label="Disable HTTPS"
description="This is an advanced option about the url retrieval way. Please enable it if Rapid Contact posts in https and your site is http.">
<option value="0">No</option>
<option value="1">Yes</option>
</field>
<field name="fixed_url"
type="radio"
default="0"
label="Fixed URL"
description="A simple solution to people that want to use Rapid Contact in an exact page. Change this to Yes and write the URL of Rapid Contact in the Fixed URL Address parameter">
<option value="0">No</option>
<option value="1">Yes</option>
</field>
<field name="fixed_url_address"
type="text"
default=""
label="Fixed URL Address"
description="If fixed url is true, this address is used for Rapid Contact to post itself."/>

<field name="spacer4" type="spacer" hr="true"/>
<field name="spacert5" type="spacer" class="text" label="&lt;strong&gt;Anti-spam Parameters&lt;/strong&gt;"/>
<field name="enable_anti_spam"
type="radio"
default="1"
label="Enable Anti-spam"
description="Enable this to use the anti-spam question for anti-spam control">
<option value="0">No</option>
<option value="1">Yes</option>
</field>
<field name="anti_spam_q"
type="text"
default="How many eyes has a typical person?"
label="Anti-Spam Question"
description="A small text question, preventing you from every automated spam" />
<field name="anti_spam_a"
type="text"
default="2"
label="Anti-Spam Answer"
description="The correct answer to the anti-spam question" />
<field name="anti_spam_position"
type="radio"
default="0"
label="Anti-Spam Position"
description="The anti-spam position, relative to the Rapid Contact form.">
<option value="0">Before</option>
<option value="1">After</option>
</field>

<field name="spacer5" type="spacer" hr="true"/>
<field name="spacert6" type="spacer" class="text" label="&lt;strong&gt;Module Class Suffix Parameter&lt;/strong&gt;"/>
<field name="moduleclass_sfx"
type="text"
default=""
label="Module Class Suffix"
description="If you want to apply a custom style, change this class suffix." />
</fieldset>
<fieldset name="advanced">
<field name="cache" type="list"
default="1" label="Caching"
description="Select whether to cache the content of this module">
<option value="1">Use global</option>
<option value="0">No caching</option>
</field>
<field name="cache_time" type="text"
default="900" label="Cache Time"
description="The time before the module is recached" />
</fieldset></fields></config>
</extension>

I even can see the field named "Nombre" in joomla interface but it is not sending message. Could you tell me where I have a mistake?

Thank you in advance. I know it is complex.

URL: cpcmetepec.com.mx/pruebas/

I´ll send you my login info in report to moderator.

Susana Garduño

Please Log in to join the conversation.

More
11 years 9 months ago #27311 by susanagarduno1
Sorry for bother you.

My form is working I was receiving the messages in my spam folder. :blush:

Thanks for your patience.

Susana Garduño

Please Log in to join the conversation.

More
11 years 9 months ago #27331 by ivan.milic
For such help you would need to pay us for custom work

Please Log in to join the conversation.

Time to create page: 0.199 seconds
Powered by Kunena Forum