Using reCaptcha plugin in component

650 views
Skip to first unread message

Viper

unread,
Mar 23, 2013, 4:53:07 PM3/23/13
to joomla-de...@googlegroups.com
How to use this plugin in my own component?

tomfuller

unread,
Mar 23, 2013, 7:24:11 PM3/23/13
to joomla-de...@googlegroups.com
Try this post: http://stackoverflow.com/questions/12840015/how-to-use-joomla-recaptcha-plugin-to-my-custom-module

Joomla com_content uses it so you can also look through the code for how they do it.

Viper

unread,
Mar 24, 2013, 5:43:48 AM3/24/13
to joomla-de...@googlegroups.com
It's not working. Just blank <div>. But in requests I see 1 request to reCaptcha server. Looks like the <div> does't correctly processed by the plugin on onInit event.
Any suggestion?

tomfuller

unread,
Mar 24, 2013, 10:10:15 AM3/24/13
to joomla-de...@googlegroups.com
Did you get a public/private key? There are some things you have to do if you are using localhost.

Read more here: https://developers.google.com/recaptcha/


On Saturday, March 23, 2013 1:53:07 PM UTC-7, Viper wrote:

Viper

unread,
Mar 24, 2013, 10:25:21 AM3/24/13
to joomla-de...@googlegroups.com
Yes. I have 2 keys. I'm not using localhost at all. Plugin in Joomla tuned up and published and in general settings allready selected.
So maybe I'm wrong. This is my small code:

view.html.php
class ComponentViewComponent extends JViewLegacy {
    public function display($tpl = null) {
... // some code

        JPluginHelper::importPlugin('captcha');
        $dispatcher = JDispatcher::getInstance();
        $dispatcher->trigger('onInit','dynamic_recaptcha_1');

        parent::display($tpl);
    }
}


template

<form id="comment-form">
    <textarea id="form-editor"></textarea>
    <div id="dynamic_recaptcha_1"></div>
    <br /><input type="submit" value="<?php echo JText::_('JSUBMIT'); ?>" />
</form>

Viper

unread,
Mar 24, 2013, 10:48:48 AM3/24/13
to joomla-de...@googlegroups.com
This is response from reCaptcha server
var RecaptchaState = {'programming_error' : 'An internal error occurred: 4D8ACC1E05650.ADF4B06.6E59'};

Glenn Arkell

unread,
Mar 24, 2013, 10:15:14 PM3/24/13
to joomla-de...@googlegroups.com
Hi Viper,

I included reCaptcha in my simple component by setting up reCaptch in the usual contact form and then included the following code to bring it in.  Possibly not the "right" or maybe "best" way but it worked for me.

In your front-end model XML file include;

        <field
            name="captcha"
            type="captcha"
            label="COM_USERS_CAPTCHA_LABEL"
            description="COM_USERS_CAPTCHA_DESC"
            validate="captcha"
        />

And then in your default.php view place the following where you want reCaptcha to show up.

            <div class="control-group">
                <div class="control-label"><?php echo $this->form->getLabel('captcha'); ?></div>
                <div class="controls"><?php echo $this->form->getInput('captcha'); ?></div>
            </div>

I think this is all I did.....  Good luck.

Glenn
Reply all
Reply to author
Forward
0 new messages