Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
29 posts Page 3 of 3
I was wondering though...is there a way to prevent the honeypot fields being added to k_success and being sent?

Sure. You can be much more specific about what gets sent by a successful submission. Your code simply sends all of the fields by using <cms:show k_success />.
Code: Select all
<cms:send_mail from=k_email_from to=k_email_to subject="<cms:get_custom_field 'site_name' masterpage='globals.php' /> Contact Form">
    <cms:show k_success />
</cms:send_mail>

Instead you can show each field separately and leave out the unnecessary ones.
Code: Select all
<cms:send_mail from=k_email_from to=k_email_to subject="<cms:get_custom_field 'site_name' masterpage='globals.php' /> Contact Form">
Name: <cms:show frm_name />
Email: <cms:show frm_email />

Message:
<cms_show frm_message />
</cms:send_mail>

For myself, I use the user's email as the "from" parameter of the send_mail tag. That way I can simply reply to the email in order to respond. It's possible that some hosts might balk at this, but I've never had any trouble.
Code: Select all
<cms:send_mail from="<cms:show frm_name/> <<cms:show frm_email/>>"  to=k_email_to subject="<cms:get_custom_field 'site_name' masterpage='globals.php' /> Contact Form"><cms:show frm_message /></cms:send_mail>


I'm glad that you included my custom tag in your boilerplate. :) Everyone is of course free to use it in any way without restrictions.
For myself, I use the user's email as the "from" parameter of the send_mail tag. That way I can simply reply to the email in order to respond. It's possible that some hosts might balk at this, but I've never had any trouble.

@Tim, a better way would be to use the 'reply_to' parameter of cms:send_mail instead.
You are correct in being apprehensive about using a foreign email address as the 'from' field - some hosts will consider this as 'mail relaying' and might refuse to send the mail.
Thanks Tim!! I didn't even think about doing it like that lol :)
KK wrote: Of course, with a little more effort you can have an array of questions (can even use repeatable regions or cloned pages for storing the questions) and then display them randomly.


I made a copy-paste code for this. Only used a <cms:each /> mod to count total number of questions in list and have startcount parameter. Used that total number to select one randomly. Comments /** can be removed. A small php function also doesn't stink.

Code: Select all

/** List of potential questions and answers
<cms:capture into='questions'>
    What color is the sky? | blue ;
    What is 1+1? | 2 ;
    What is the color of grass? | green ;
    Are you a robot? | no ;
    Are you human? | yes
</cms:capture>

/** Take a random question from list
<cms:each questions sep=';' as='question' startcount='1'>
    <cms:if k_count='1' >
        <cms:set random_number = "<cms:php>echo (rand(1,<cms:show k_total_count />));</cms:php>"/>
    </cms:if>
    <cms:if k_count=random_number>
        <cms:set antispam_question = question scope='global'/>
    </cms:if>
</cms:each>

/** Save question and answer separately
<cms:if "<cms:not antispam_question />" >
    /** if list is gone.. breathe and set defaults
    <cms:set antispam_question = 'What color is the sky?' scope='global'/>
    <cms:set antispam_answer = 'blue' scope='global'/>
<cms:else />
    <cms:each antispam_question as='piece'>
        <cms:if k_count='0'>
            <cms:set antispam_question = piece scope='global'/>
        <cms:else_if k_count='1'/>
            <cms:set antispam_answer = piece scope='global'/>
        </cms:if>
    </cms:each>
</cms:if>

/** Prepare a hint for a human
<cms:set count = "<cms:php>echo strlen('<cms:show antispam_answer />');</cms:php>" /> /** use mb_strlen if non-latin characters
<cms:if  count eq '1' >
    <cms:set answer_hint = '1 character' scope='global' />
<cms:else_if  count gt '1' />
    <cms:set answer_hint = "<cms:concat count ' characters' />" scope='global' />
<cms:else />
    <cms:set answer_hint = 'Unknown error' scope='global' />
</cms:if>

/** Remember the correct answer
<cms:set_flash name='antispam_answer' value=antispam_answer />



Code sets 3 variables: antispam_question, answer_hint, antispam_answer.
And validator pattern will match the correct answer after the form submits and page reloads.

Code: Select all
<label class="required" for="human">
   <cms:show antispam_question /> (<cms:show answer_hint />)
   <em>* <cms:if k_error_human>Please answer the question</cms:if></em>
</label>
<cms:input type="text" required='1' validator="regex=/^<cms:get_flash 'antispam_answer' />$/i" class="input-text required-entry" id="human" name="human"/>



If the list, established in code above, must be edited in backend, here is a definition of repeatable region:
Code: Select all

<cms:repeatable name='security_questions' order='20' label='List of security questions for antispam'>
    <cms:editable type='text' col_width='300' label='Question' name='security_question'  />
    <cms:editable type='text' col_width='100' label='Answer' name='security_answer'  />
</cms:repeatable>



Screenshot:
ScreenCut-01-14---22-20-46-.png
ScreenCut-01-14---22-20-46-.png (20.15 KiB) Viewed 1004 times


And code can be changed as follows:
Code: Select all
/** List of potential questions and answers
<cms:capture into='questions'>
    <cms:show_repeatable 'security_questions' >
        <cms:show security_question /> | <cms:show security_answer /> ;
    </cms:show_repeatable>
</cms:capture>
Hi KK,
I think the stopforumspam does not work with PHP version 7

Deprecated: Non-static method StopForumSpam::stop_spam_handler() should not be called statically in /home/evropest/domains/evropest/panel/parser/parser.php on line 481

Warning: Cannot modify header information - headers already sent by (output started at /home/evropest/domains/evropest/panel/parser/parser.php:481) in /home/evropest/domains/evropest/panel/tags.php on line 6548

Can it adapt?
Thanks
@orbital,

As mentioned in the original post starting this thread -
UPDATE: With Couch v1.4, the DataBound Forms addon ships with a native tag cms:check_spam that does same job as cms:stop_spam tag mentioned in the discussion above.

So instead of this addon, please use the native <cms:check_spam> tag.
I don't think that tag will show this error.

Hope it helps.
Thanks KK,

I'm sorry I did not pay attention to that, but a similar problem exists with too_many_urls

Deprecated: Non-static method TooManyUrls::too_many_urls_handler() should not be called statically in /home/evropest/domains/evropest/panel/parser/parser.php on line 481

Warning: Cannot modify header information - headers already sent by (output started at /home/evropest/domains/evropest/panel/parser/parser.php:481) in /home/evropest/domains/evropest/panel/tags.php on line 6548


Can you look at it?

Thanks
Fixed. Please download the addon again.
Thanks for the maintenance :D
29 posts Page 3 of 3

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 1 guest