Integration
You'll need to put on your code editing hat and dive into a couple of files
Unfortunately the Magento templates for the contact, reviews and send to friend do not support automatically adding the reCAPTCHA widget to these forms.
You'll have to do this manually, so open up your favorite editor and let's figure it out.
Contacts Form Integration
On the contacts page
If you want to display the reCAPTCHA widget on the contact form at http://www.your-site.com/contacts/
, the relevant Layout XML code is as follows:
<contacts_index_index>
<reference name="contactForm">
<block type="studioforty9_recaptcha/explicit" name="studioforty9.recaptcha.explicit" template="studioforty9/recaptcha/explicit.phtml"/>
</reference>
</contacts_index_index>
We've automatically added this Layout XML code for you, so all you have to do is add the PHP code to display the HTML of the block.
Simply, find your contact form's template, for example, in RWD, it's /app/design/frontend/rwd/default/template/contacts/form.phtml
and add the following code anywhere between the <form>
tags, preferably towards the end of the form.
<?php echo $this->getChildHtml('studioforty9.recaptcha.explicit'); ?>
That's it, the widget should display as long as you've selected it in the configuration settings under System-> Configuration -> Sales -> Google API -> Google reCAPTCHA
.
On any CMS page
If you want to display the contact form on a CMS page in the Magento Admin area, go to the desired CMS page in the Magento Admin area, click on the Design
tab and paste in the following under Layout Update XML
:
<reference name="content">
<block type="core/template" name="contactForm" template="contacts/form.phtml">
<action method="setFormAction"><value>/contacts/index/post</value></action>
<block type="studioforty9_recaptcha/explicit" name="studioforty9.recaptcha.explicit" template="studioforty9/recaptcha/explicit.phtml">
<action method="setAllow"><value>true</value></action>
</block>
</block>
</reference>
Review Form Integration
You have 2 options to use reCAPTCHA on the out-of-the-box review form.
Layout XML and no template changes
In your design theme under layout/local.xml
, add the following Layout XML.
<review_product_list>
<reference name="product.review.form.fields.before">
<block type="studioforty9_recaptcha/explicit" name="studioforty9.recaptcha.explicit" template="studioforty9/recaptcha/explicit.phtml"/>
</reference>
</review_product_list>
Layout XML and one template change
We've already added the following Layout XML to our extension for simplicity, all you need to do is add the PHP code to your template.
<review_product_list>
<reference name="product.review.form">
<block type="studioforty9_recaptcha/explicit" name="studioforty9.recaptcha.explicit" template="studioforty9/recaptcha/autorender.phtml"/>
</reference>
</review_product_list>
In your review template, for example, in RWD, /app/design/frontend/rwd/default/template/sendfriend/send.phtml
, add the PHP code below anywhere between the <form>
tags, preferably toward the end of the form.
<?php echo $this->getChildHtml('studioforty9.recaptcha.explicit'); ?>
Using a theme or extension to display reviews on the product page?
While we don't support adding the reCAPTCHA widget on those forms, we've got some hints in the Troubleshooting section. We also offer paid support through our company StudioForty9
Send to Friend Form Integration
We've already added the Layout XML below for simplicity, you just need to add the PHP code to your template/
<sendfriend_product_send>
<reference name="sendfriend.send">
<block type="studioforty9_recaptcha/explicit" name="studioforty9.recaptcha.explicit" template="studioforty9/recaptcha/explicit.phtml"/>
</reference>
</sendfriend_product_send>
In your send to friend form template, for example, in RWD, /app/design/frontend/rwd/default/template/sendfriend/send.phtml
, add the PHP code below anywhere between the <form>
tags, ideally toward the end of the form.
<?php echo $this->getChildHtml('studioforty9.recaptcha.explicit'); ?>
Updated less than a minute ago