custom spamblock-hook for contact-form plugin
Posted: Mon Feb 04, 2008 7:38 pm
Hi s9y-community,
I am using the contact-form plugin, but didn't like the fact, that the text above the submit-button is the same as for normal comments. See this example:
So I decided to give it a try, hacked around a bit and ended up with a new spamblock-hook to enable a custom message for the contact-form.
From my first tests, this seems to work but anyway I would like to present my changes to the s9y-wizards, in case I have made any mistake. If anyone else likes my changes, maybe they can find their way into the contact-from plugin someday ???
So, here's what I did ...
OPEN
plugins/serendipity_event_spamblock/serendipity_event_spamblock.php
FIND
AFTER, ADD
FIND within the function event_hook()
COPY
Make a copy of that complete case-block and rename it to:
In the copied block I SEARCHED for:
and REPLACED it with this:
OPEN
plugins/serendipity_event_contactform/plugin_contactform.tpl
FIND
REPLACE WITH
OPEN
plugins/serendipity_event_contactform/plugin_dynamicform.tpl
FIND
REPLACE WITH
I had to learn, that this was not the complete trick, because smarty complained about an illegal hook 
OPEN
include/functions_smarty.inc.php
FIND
AFTER, ADD
I am pretty sure, that my last hack(on the functions_smarty.inc.php) has a better(official) way, how it can be achieved. I guess that these hooks get added during plugin-installation, but as I added a $propbag->add('event_hooks',-Line manually I had to add that to the smarty-file too ?!
I have also tried to use a construct like this in the new case-block
But the constant that I defined in the language-file of the contact-form plugin is apparently unknown in the focus of the spamblock-plugin.
I am looking forward to your feedback ...
Cheers,
Manfred
I am using the contact-form plugin, but didn't like the fact, that the text above the submit-button is the same as for normal comments. See this example:
Both text-blocks are "triggered" via the frontend_comment-hook from within the templates of the contact-form plugin.Contact-Form wrote:Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons likeand
are converted to images.
To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
So I decided to give it a try, hacked around a bit and ended up with a new spamblock-hook to enable a custom message for the contact-form.
From my first tests, this seems to work but anyway I would like to present my changes to the s9y-wizards, in case I have made any mistake. If anyone else likes my changes, maybe they can find their way into the contact-from plugin someday ???
So, here's what I did ...
OPEN
plugins/serendipity_event_spamblock/serendipity_event_spamblock.php
FIND
Code: Select all
$propbag->add('version', '1.68');
$propbag->add('event_hooks', array(
'frontend_saveComment' => true,
'external_plugin' => true, Code: Select all
'submit_contactform' => true,Code: Select all
case 'frontend_comment':Make a copy of that complete case-block and rename it to:
Code: Select all
case 'submit_contactform':Code: Select all
echo '<br />' . PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS_USERDESC . '<br />';Code: Select all
echo '<br />My custom SPAMblock-message blablabla ...<br />';plugins/serendipity_event_contactform/plugin_contactform.tpl
FIND
Code: Select all
{serendipity_hookPlugin hook="frontend_comment" data=$commentform_entry}Code: Select all
{serendipity_hookPlugin hook="submit_contactform" data=$commentform_entry}plugins/serendipity_event_contactform/plugin_dynamicform.tpl
FIND
Code: Select all
{serendipity_hookPlugin hook="frontend_comment" data=$commentform_entry}Code: Select all
{serendipity_hookPlugin hook="submit_contactform" data=$commentform_entry}OPEN
include/functions_smarty.inc.php
FIND
Code: Select all
static $hookable = array('frontend_header',
'entries_header',
'entries_footer',
Code: Select all
'submit_contactform',I have also tried to use a construct like this in the new case-block
Code: Select all
echo '<br />' . PLUGIN_CONTACTFORM_SPAMBLOCK_MESSAGE . '<br />';I am looking forward to your feedback ...
Cheers,
Manfred