comments
Drupal sites, like any content sites, naturally receive a lot of spam comments. Any blog or blog-like site which allows unauthenticated or anonymous users to comment on posts or any content is open to spam because spammers just want to have links to their websites displayed by your website for link-building purposes which is important for SEO. Spam comments used to be much more obvious as in blatant ads for penis-enhancing drugs. Nowadays, spammers are using more sophisticated scripts that are still easy to detect - by humans and usually also by spam-detection software. New spam might praise your blog or quote something you said in your blog post or just say something generic, perhaps on a related topic or perhaps not related at all. Then they will have their spam website in the URL field, if not also in the comment text. If the website has keywords which are totally unrelated to your blog, you can bet it's spam.
What can a Drupal website do about spam?
One old solution for spam, a common plugin on WordPress sites, is called Akismet. Akismet is a service and requires you to create an account and get an API key from them. Then they will help you detect spam.
Drupal has something like Akismet but improved and it was created by the Drupal creator himself. It's called Mollom, and it's also a cloud-based service, and you also create an account with them. Mollom is free to use although there are some paid services. I use Mollom on this blog. It catches hundreds of spam comments for me but also lets in a single false negative per day or so. I wouldn't have been able to turn on comments without turning on Mollom as I would immediately be deluged with spam. But I hope that Mollom continues to improve so that I don't even get 1 spam on most days.
Since I still do get some ham and spam comments, I have to process them somehow and report the spams to Mollom so they can improve their algorithms and heuristics for the future. Unfortunately, Drupal's default comments management view doesn't easily let me see if a comment is spam or not. In order to make that decision I need to see the URL and comment text that was saved. If there was no URL, it usually isn't spam, and if there was no URL in the comment text then most certainly it isn't spam. But if there was a link in the text, I need to see what site it links to, and see if the comment is at all intelligent or relevant. You can also tell by looking at any link saved in the URL field. Since Drupal's comment management page doesn't do this, I created a view, which you can import (this is Drupal 6) below.
The thing that Drupal's comment admin page offers is bulk operations. Mollom provides some operations such as report spam to Mollom and delete. This is usually what I want to do. Unfortunately, there's no way to use Mollom's actions in Views with Views Bulk Operations! So until this issue gets resolved (http://drupal.org/node/655846) I've done the next best thing which is to have links to the Mollom management page for each comment. It will still require you to open that page, select the reporting action you want, and then submit the form though. But this workflow has at least saved me some time and now I have removed all the really spammy spam from this site.
$view = new view; $view->name = 'comments_more'; $view->description = ''; $view->tag = ''; $view->view_php = ''; $view->base_table = 'comments'; $view->is_cacheable = FALSE; $view->api_version = 2; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ $handler = $view->new_display('default', 'Defaults', 'default'); $handler->override_option('fields', array( 'name' => array( 'label' => 'Author', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'link_to_user' => 1, 'exclude' => 0, 'id' => 'name', 'table' => 'comments', 'field' => 'name', 'relationship' => 'none', ), 'homepage' => array( 'label' => 'Author\'s website', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'display_as_link' => 1, 'exclude' => 0, 'id' => 'homepage', 'table' => 'comments', 'field' => 'homepage', 'relationship' => 'none', ), 'comment' => array( 'label' => 'Body', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'exclude' => 0, 'id' => 'comment', 'table' => 'comments', 'field' => 'comment', 'relationship' => 'none', ), 'delete_comment' => array( 'label' => 'Delete link', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'text' => '', 'exclude' => 0, 'id' => 'delete_comment', 'table' => 'comments', 'field' => 'delete_comment', 'relationship' => 'none', ), 'edit_comment' => array( 'label' => 'Edit link', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'text' => '', 'exclude' => 0, 'id' => 'edit_comment', 'table' => 'comments', 'field' => 'edit_comment', 'relationship' => 'none', ), 'hostname' => array( 'label' => 'Hostname', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'exclude' => 0, 'id' => 'hostname', 'table' => 'comments', 'field' => 'hostname', 'relationship' => 'none', ), 'status' => array( 'label' => 'In moderation', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'type' => 'yes-no', 'not' => 0, 'exclude' => 0, 'id' => 'status', 'table' => 'comments', 'field' => 'status', 'relationship' => 'none', ), 'timestamp' => array( 'label' => 'Post date', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'date_format' => 'small', 'custom_date_format' => '', 'exclude' => 0, 'id' => 'timestamp', 'table' => 'comments', 'field' => 'timestamp', 'relationship' => 'none', ), 'view_comment' => array( 'label' => 'View link', 'alter' => array( 'alter_text' => 0, 'text' => '', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'text' => '', 'exclude' => 0, 'id' => 'view_comment', 'table' => 'comments', 'field' => 'view_comment', 'relationship' => 'none', ), 'cid' => array( 'label' => 'Mollom', 'alter' => array( 'alter_text' => 1, 'text' => '<a href="/mollom/report/comment/[cid]">Report to Mollom</a>', 'make_link' => 0, 'path' => '', 'link_class' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'target' => '', 'help' => '', 'trim' => 0, 'max_length' => '', 'word_boundary' => 1, 'ellipsis' => 1, 'html' => 0, 'strip_tags' => 0, ), 'empty' => '', 'hide_empty' => 0, 'empty_zero' => 0, 'link_to_comment' => 0, 'exclude' => 0, 'id' => 'cid', 'table' => 'comments', 'field' => 'cid', 'override' => array( 'button' => 'Override', ), 'relationship' => 'none', ), )); $handler->override_option('access', array( 'type' => 'none', )); $handler->override_option('cache', array( 'type' => 'none', )); $handler->override_option('css_class', 'view-comments-more'); $handler->override_option('header', '<style> .view-comments-more table { background: white; position: relative; z-index: 100; } </style>'); $handler->override_option('header_format', '2'); $handler->override_option('header_empty', 0); $handler->override_option('items_per_page', 30); $handler->override_option('use_pager', '1'); $handler->override_option('style_plugin', 'table'); $handler->override_option('style_options', array( 'grouping' => '', 'override' => 1, 'sticky' => 0, 'order' => 'desc', 'columns' => array( 'name' => 'name', 'homepage' => 'homepage', 'comment' => 'comment', 'delete_comment' => 'delete_comment', 'edit_comment' => 'edit_comment', 'hostname' => 'hostname', 'status' => 'status', 'timestamp' => 'timestamp', 'view_comment' => 'view_comment', ), 'info' => array( 'name' => array( 'sortable' => 1, 'separator' => '', ), 'homepage' => array( 'sortable' => 1, 'separator' => '', ), 'comment' => array( 'separator' => '', ), 'delete_comment' => array( 'separator' => '', ), 'edit_comment' => array( 'separator' => '', ), 'hostname' => array( 'sortable' => 0, 'separator' => '', ), 'status' => array( 'sortable' => 0, 'separator' => '', ), 'timestamp' => array( 'sortable' => 1, 'separator' => '', ), 'view_comment' => array( 'separator' => '', ), ), 'default' => 'timestamp', )); $handler = $view->new_display('page', 'Page', 'page_1'); $handler->override_option('path', 'views/comments_more'); $handler->override_option('menu', array( 'type' => 'none', 'title' => '', 'description' => '', 'weight' => 0, 'name' => 'navigation', )); $handler->override_option('tab_options', array( 'type' => 'none', 'title' => '', 'description' => '', 'weight' => 0, 'name' => 'navigation', ));
- tomo's blog
- Login to post comments
- Comments
Drupal 6 allows you to either display the comment form below saved comments or on a separate page. There's surprisingly no way to configure the form to appear above the comments. It's hard-coded at the bottom of comment_render to either append the form, or not at all.
There's a micro-module aptly titled 'Comment form above comments' which does the job but does so using string replaces on resulting html so it's not the ideal or elegant solution.
It turns out to be simple to get the same effect in code.
First, we need to "configure" the form to appear on a separate page, but only because we're going to manually show it. You can ensure this configuration with the line:
variable_set('comment_form_location_'.$node->type, COMMENT_FORM_SEPARATE_PAGE);
You could even variable_get and re-variable_set after printing the form if you really wanted to.
Next, output the following where you want to display comments, whether in a PHP code block or node template:
$edit = array('nid' => $node->nid); print comment_form_box($edit) . comment_render($node);
Another recent discovery was that the comment form is hard-coded to redirect to /node after submitting. This hack, as a module, will get you back to the page you submitted from:
function noredirect_comment_form_submit(&$form, &$form_state) { $form_state['redirect'] = ltrim($form['#action'], '/'); }
function noredirect_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'comment_form') { $form['#action'] = request_uri(); $form['#submit'][] = 'noredirect_comment_form_submit'; } }
Recent comments
1 year 11 weeks ago
2 years 3 days ago
2 years 1 week ago
2 years 3 weeks ago
2 years 19 weeks ago
2 years 19 weeks ago
2 years 19 weeks ago
2 years 19 weeks ago
2 years 19 weeks ago
2 years 19 weeks ago