Add this to the $tables['signup'] array inside of the signup_views.inc file

      'signup_total' => array(
        'name' => t('Signup: Node: Signup Total'),
        'handler' => 'views_handler_field_signup_total',
        'notafield' => TRUE,
        'sortable' => FALSE,
        'help' => t('Number of users who have signed up.'),
      ), 

And the handler function you need to add is this

/**
 * Displays a field with the total of signups for this node.
 */
function views_handler_field_signup_total($fieldinfo, $fielddata, $value, $data) {
  return db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE nid = %d", $data->nid));
}

cheers,
Katrina

Comments

ambereyes’s picture

Also, in order to see this field in Views, you will need to empty the cache after adding this code to the file. I use the developer module for this, makes it very easy.

dww’s picture

Status: Active » Closed (duplicate)

Thanks, but please search for existing issues first. ;)
#179585: Signup count field in Views 7.x

socialnicheguru’s picture

subscribing

kassissieh’s picture

I updated this for Drupal 6. I'm not sure whether modifying Signup is the best way to do this, or this could be better accomplished at the theme layer. I'd appreciate your advice/code on this. This code outputs x / y, where x is the # of users signed up for a node and y is the signup limit for the node.

Create file signup_handler_field_signups_total.inc


/**
* Displays a field with the total of signups for this node.
*/
class signup_handler_field_signup_total extends views_handler_field {
  function render($values) {
    // var_dump($values);
    return db_result(db_query("SELECT COUNT(*) FROM {signup_log} WHERE nid = %d", $values->nid)) . ' / ' . $values->signup_close_signup_limit;
  }
}

In file signup_views.inc, add this to the array in function signup_views_handlers:

      'signup_handler_field_signup_total' => array(
        'parent' => 'views_handler_field',
      ),

... and add this to the signup log array:

  $data['signup_log']['signup_total'] = array(
    'title' => t('Signup Total'),
    'real field' => 'uid',
    'field' => array(
      'handler' => 'signup_handler_field_signup_total',
      'help' => t('Number of users who have signed up.'),
    ),
daniel sanchez’s picture

I'm trying this on Drupal 6 and am getting the error:
Error: handler for signup_log > signup_total doesn't exist!

What folder is signup_handler_field_signups_total.inc supposed to be in?

kardave’s picture

subscribing....
(Events, Views, Signup, Drupal 6.x)

ryan88’s picture

I am having the same problem. I installed the code as directed, and it appears to work, I can see the field in views, but when I add it, I get the error in views, "Error: handler for signup_log > signup_total doesn't exist!."

EDIT: Fixed this, it says to name the new file "signup_handler_field_signups_total.inc" but it should be "signup_handler_field_signup_total.inc". Notice the singular signup. This should fix the problem.

dww’s picture

@all: Once an issue is marked duplicate, please read the other issue and comment there, don't continue to post to the duplicate issue.