Any Captcha for v1.4?

Topics: Customizing Orchard, Installing Orchard, Writing modules
Mar 4, 2012 at 5:14 PM
Edited Mar 4, 2012 at 5:40 PM

The closest thing I can find to contact forms or comments with captcha are both relying on RoutParts.

CyberStride appears to be missing captcha

oForms seems to have it but I havn't played with it but it also relies on RoutPart.

 I've toyed with the source on but of the above and should have luck but it doesn't solve the issue of Captcha for comments.

Dndz.Industries looks like exactly what I need but it isn't showing up even after adding it to the comments part yet the validation *is* showing up because I can't submit a comment.

Any tips on the best way to get this done?  

 

==============================

Update, after converting this post from Russian to English I was able to see I should be adding the Captcha to the BlogPost, not the comments.  After doing so it shows up.  Unfortunately my next issue is that it never accepts my captcha input.  Debugging shows that the 

 

DefaultCaptchaService.cs is trying to pull the results from the Request params but none of the three fields it wants are available:

var contentTypeFieldValue = curHttpContext.Request.Params[contentTypeFieldName];

The three fields it wants is based on this:

internal const string CAPTCHA_DEFAULT_TEXTBOX_NAME = "captchaattempt";        
internal const string CAPTCHA_DEFAULT_GUID_FIELD_NAME = "captchaguid";        
internal const string CAPTCHA_DEFAULT_CONTENTITEM_FIELD_NAME = "captchacontentitem";

In the HTML, all are certainly there:

<div class="postinput shape-tracing-selected" shape-id="9">
        <img src="/Dndz.Industries/CaptchaImage/Render?challengeGuid=ecc23fb4-aee3-4db0-bbe3-c18ac5c0ae77&amp;contentType=BlogPost" shape-id="9" class="shape-tracing-selected">
        <input id="captchaguid" name="captchaguid" type="hidden" value="ecc23fb4-aee3-4db0-bbe3-c18ac5c0ae77" shape-id="9" class="shape-tracing-selected">
        <p shape-id="9" class="shape-tracing-selected">
            <input class="comment shape-tracing-selected" id="captchaattempt" name="captchaattempt" size="22" type="text" value="" shape-id="9">
            <small shape-id="9" class="shape-tracing-selected">Verification letters</small>
        </p>
    </div>

Mar 4, 2012 at 6:09 PM

Okay,  i got it figured out.  

http://nongreedy.ru/javanet/%D0%BF%D1%80%D0%B8%D0%BA%D1%80%D1%83%D1%87%D0%B8%D0%B2%D0%B0%D0%B5%D0%BC-%D0%BA%D0%B0%D0%BF%D1%82%D1%87%D1%83-%D0%B2-orchard-cms

Middle of the page, it talks about overriding the Parts.Comments.cshtml and Parts.Captcha.cshtml in your theme.

Not sure I understand the overriding of the Parts.Captcha....however I get the need to override the parts.Comments.cshtml since both are modules....how do you know which cshtml takes priority?

Developer
Mar 4, 2012 at 6:14 PM

Templates in your theme will always override the ones that are defined in the modules themselves, so simply copying the Parts.Comments.cshtml and Parts.Captcha.cshtml to the Views folder of your theme should be enough.

Mar 4, 2012 at 6:33 PM

Thanks, I get that part but I'm curious when two modules both want to modify the same cshtml in the theme is the only place to know one takes priority over the other?

My issue is that the module's functionality depends entirely on the enabled theme which is definately not ideal if I want to change the theme, my site is ugly and broken. The theme is a creative solution but it hijacks the intent of theme cshtml files.

Ideally, both of these cshtml files should be in the module itself and based on the fact than captcha lists comments as a dependancy, orchard would know that the cshtml in captcha takes prioirity.

If I want to override the cshtml in my theme I still could. Then my site could beugly but at least it isn't broken.

Orchard v1.5 feature?

PS> this is not an attack on the module creator (the thing is brilliant) and I myself find too often I enable creative solutions through a theme just wondering if there is an alternative now or in the future.

--------
John
Sent from a mobile phone

On Mar 4, 2012 12:14 PM, "sfmskywalker" <notifications@codeplex.com> wrote:

From: sfmskywalker

Templates in your theme will always override the ones that are defined in the modules themselves, so simply copying the Parts.Comments.cshtml and Parts.Captcha.cshtml to the Views folder of your theme should be enough.

Read the full discussion online.

To add a post to this discussion, reply to this email (orchard@discussions.codeplex.com)

To start a new discussion for this project, email orchard@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Developer
Mar 4, 2012 at 6:59 PM
Edited Mar 4, 2012 at 7:00 PM

I most certainly agree that it's not ideal if the module's functionality entirely depends on the enabled theme.

In any case, If I understand you correctly, you want to have a modified Parts.Comments.cshtml distributed with the captcha module. Well, you most certainly should be able to do it. Just make sure that the template you store there is more specific than the default template that comes with the Comments module.

For example, you could copy Parts.Comments.cshtml from Orchard.Comments to the views folder of the Captcha module. Next, rename the copied view into: Parts.Comments-BlogPost.cshtml (since you will most likely display the comments and captcha below a blog post).

You see, Orchard generates so called Alternates, which are simply put filenames to look for to render a certain shape. The list is sorted so that the most specific alternate takes precedence over the less-specific ones.

I didn't test it, but it should work.

Mar 4, 2012 at 7:27 PM

Beautiful response!

--------
John
Sent from a mobile phone

On Mar 4, 2012 12:59 PM, "sfmskywalker" <notifications@codeplex.com> wrote:

From: sfmskywalker

I most certainly agree that it's not ideal if the module's functionality entirely depends on the enabled theme.

In any case, If I understand you correctly, you would want to have a modified Parts.Comments.cshtml distributed with the captcha module. Well, you most certainly should be able to do it. Just make sure that the template you store there is more specific than the default template that comes with the Comments module.

For example, you could copy Parts.Comments.cshtml from Orchard.Comments to the views folder of the Captcha module. Next, rename the copied view into: Parts.Comments-BlogPost.cshtml.

You see, Orchard generates so called Alternates, which are simply put filenames to look for to render a certain shape. The list is sorted so that the most specific alternate takes precedence over the less-specific ones.

I didn't test it, but it should work.

Read the full discussion online.

To add a post to this discussion, reply to this email (orchard@discussions.codeplex.com)

To start a new discussion for this project, email orchard@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Developer
Mar 4, 2012 at 7:33 PM

Even more so if it actually works :)