Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact form with recaptcha on cms page #52

Closed
tomi02 opened this issue Mar 23, 2018 · 3 comments
Closed

Contact form with recaptcha on cms page #52

tomi02 opened this issue Mar 23, 2018 · 3 comments

Comments

@tomi02
Copy link

tomi02 commented Mar 23, 2018

1.7.2.2 - Your prestashop version
2.0.4 - Eicaptcha Version
classic/modified - Do you use a specific theme
Issue description
Hi
I put the contact form on the cms page in the following way:
/themes/classic/templates/cms/page.tpl
I added:

{if $ cms.id == 8}
      {widget name = "contactform"}
{/} If

id == 8 - id cms with contact form

/themes/classic/modules/contactform/views/templates/widget/contactform.tpl

<form action="{$urls.pages.contact}" method="post" {if $contact.allow_file_upload}enctype="multipart/form-data"{/if}>

I exchange for:

{if isset ($ cms) && $ cms.id == 8}
      <form action = "{$ link-> getCMSLink (8)}" method = "post" {if $ contact.allow_file_upload} enctype = "multipart / form-data" {/ if}>
} Else {
      <form action = "{$ urls.pages.contact}" method = "post" {if $ contact.allow_file_upload} enctype = "multipart / form-data" {/ if}>
{/} If

But unfortunately the recaptcha is not displayed in the contact form on the cms page.
Is there any possibility that eicaptcha would also work on the cms page?

@nenes25
Copy link
Owner

nenes25 commented Mar 24, 2018

Hello,

In order to make it work with your implementation, you need to edit the line : https://github.com/nenes25/eicaptcha/blob/17/eicaptcha.php#L314
and to add
|| $this->context->controller instanceof CmsController

So the specific js will be loaded in cms page too.

Regards,

@tomi02
Copy link
Author

tomi02 commented Mar 24, 2018

Hello
Thank you for your answer.
I added to the eicaptcha.php
//Add Content box to contact form page in order to display captcha if ( $this->context->controller instanceof ContactController || $this->context->controller instanceof CmsController && Configuration::get('CAPTCHA_ENABLE_CONTACT') == 1)

On the cms page, the head section has been added
<link rel="stylesheet" href="http://xxx/modules/eicaptcha/views/css/eicaptcha.css" type="text/css" media="all">

It has not been added
<script type="text/javascript"> //Recaptcha CallBack Function var onloadCallback = function() {grecaptcha.render("captcha-box", {"theme" : "light", "sitekey" : "6Ldv3EsUAAAAACjUJxxxxxxxxxxxx"});}; </script><script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit&hl=" async defer></script>

In body section was added only
<div id="captcha-box"></div>
It has not been added
<div id="captcha-box"><div style="width: 304px; height: 78px;"><div><iframe src="https://www.google.com/recaptcha/api2/anchor?k=6Ldv ......

So the recaptcha window did not appear on the cms page.
Regards.

Edit
In eicaptcha.php I added
|| $this->context->controller instanceof CmsController
In this place:
https://github.com/nenes25/eicaptcha/blob/17/eicaptcha.php#L329
if ( $this->context->controller instanceof ContactController || $this->context->controller instanceof AuthController || $this->context->controller instanceof CmsController )
And everything started working
Thank you.

@nenes25
Copy link
Owner

nenes25 commented Mar 24, 2018

OK great if it works :-)
So i close the issue

Regards,

@nenes25 nenes25 closed this as completed Mar 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants