Is there any way besides hacking your own templates to get additional fields into comments? For instance if I want a "country" field or "shoe size" dropdown.

This sort of functionality is availible for content types but not for comments, I have been able to easily hook image uploads to comments but see no other modules/setting to add custom fields.

I have tried the nodecomments module and it does work but for data gathering and usability I cannot have each comment as a seperate node, they must be part of a parent node. The main reason is gathering data for the voting api becomes to complicated. I want users to give a rating in the comments that is then tallied as an average for the node.

Anyhow is there any easy way to add some more functionality to the comments?

Comments

coreyp_1’s picture

Sure, there's another way.

You can use hook_form_alter() in a custom module to add the desired form elements to the comment form. Then use the theming overrides to pull the pertinent information from the database and display it when the comment is rendered.

No hacking needed at all.

- Corey

teamrob’s picture

So I would basically create a mini-module with code like the following for all the custom input fields I would need,

<?php
function mymodule_form_alter($form_id, &$form){
$form['details']['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Describe it'),
    '#default_value' =>  variable_get('description', ''),
    '#cols' => 60,
    '#rows' => 5,
    '#description' => t('Log description.'),
}

The I would call it using a custom comment.tpl.php with something like?

<?php
print drupal_render($form['details']); 
?>

The code might be slighly off I havent looked into the form api but Is that the basic structure for using hook_form_alter() ?

thanks