This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Simple Spam Block

I have added a simple spam catcher by simply adding a form element with the question "What is 2 + 3?" and adding an additional validation point. I thought I would offer this to the group...

Now I am sure the best approach would be to create a separate module for this (so I can more easily upgrade without overriding my changes..) but I just don't have a full understanding of extending existing modules just yet. If anyone has a good handle on how to do that, I'd love to change this to use that.

Another possible feature enhancement would be to have it generate a random math equation (but nothing that would require a result > 9). I would add that if I could extend the existing module, but I am hesitant to do it with my current edits directly in comment.module.

Anyways... here is my implementation (based on 4.7):

In the comment_form function, add the following line of code right after the line that says $form['homepage'].... I found two instances. (This extra field is for anonymous posters only):

$form['spam_block'] = array(
  '#type' => 'textfield',
  '#title' => t('What is 2+3?'),
  '#maxlength' => 255,
  '#size' => 30,
  '#default_value' => '',
  '#description' => t('Just type the number 5 here.  This is to prevent spam.'),
  '#required' ==> TRUE
);

and then in the comment_validate function, within the if (!$user->uid || isset($edit['is_anonymous'])) block, add this line of code at the end:

if ( $edit['spam_block'] != '5' ) {
  form_set_error('spam_block', t('You have to enter the number 5 here.'));
}

And that's it! Hope this is useful to someone. Please test this out if planning on using in production, as I certainly haven't tried this with a ton of modules and scenarios, but it works for me... Also, if anyone has some thoughts on how this could be setup as an extension module (rather than editing core), please let me know.

Cheers!

There must be some decent email trackers around?

There must be some decent email trackers around? So the user gets notified when a new topic is created or when someone replies to their topic?

I've seen a 'comment mail' module but its not yet ported to v5....

Could anyone point me to a suitable one please?

hook_menu troubles - foo/bar/ and foo/ both points to foo/

I'm digging deeper into drupal now, and I'm currently stuck in a hook_menu issue:

I got these in my foo_menu():

REQUEST: horizontal newsticker

Hi,

i search for a possibility (better a module) for displaying news like apple.com. This is a horizontal ticker integrated in the homepage (and only homepage, one page).

I know the taxonomy ticker module. Yes, but horizontally...

Is there any solution or fix out there?

thx in advance
paulap

Extending views_rss

I am tying to use views_rss to provide an RSS feed of CCK content. Unfortunately, the views_rss module seems to only map standard node fields to the RSS fields so there doesn't seem to be a way to have my CCK fields included in the feed.

Can I develop a module that extends the views module to customize the RSS output (http://drupal.org/node/103475 seems to suggest that). If so, how do I do this (I've created custom modules and customized duplicates of modules, but have never extended an existing module)?

CCK + imagecache + imagefield questions

Using the latest CCK + imagefield + imagecache :

1- Is it possible to have to have associated captions for each image?

2- Upload and attach images to nodes programmatically? Pretty much sure it is, just don't have a clue on the 'how'. I can already upload the images myself to my directory, but I need to attach the images to the node.

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions