Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I need to check spam in CCK fields but spam module allow to check only title and body
So i made a little dirty hack to allow spam filters works with CCK fields
I just modified spam_get_text() function in spam.module
function spam_get_text($content, $type, $fields, $extra = array(), $full = TRUE) {
if (is_object($content)) {
$content = (array)$content;
}
/*Dirty hack to concatenate all cck fields into body*/
if ($type == 'node') {
foreach($content as $field => $value) {
if (strpos($field, 'field_') === 0) {
$content['body'] .= ' '. $value[0]['value'];
}
}
}
$text = '';
foreach ($fields['main'] as $field) {
$text .= $content[$field] .' ';
}
if ($full && is_array($fields['other'])) {
foreach ($fields['other'] as $field) {
$text .= $content[$field] .' ';
}
}
return $text;
}
I understand that this solution is not very good - but it works for me
Comments
Comment #1
AlexisWilke CreditAttribution: AlexisWilke commentedYes. We'd need to add a content/spam_content_cck.inc file that would take care of the CCK fields.
Your fix would imply that everyone has CCK installed.
Thank you for posting it though. That's a good start for CCK support.
Alexis Wilke
Comment #2
Eugene Fidelin CreditAttribution: Eugene Fidelin commentedYes my solution imply that everyone has CCK installed and also it doesn't work with multivalued CCK fields, thought it is very easy to fix
Comment #3
apadernoI am closing this issue, since it's for a Drupal version no longer supported.