2

I am trying to create a view that will count the number of submissions that a particular webform has.

So far I have added the field: Webform: Webform submission count

and added in a Node:ID filter to the ID of my webform.

When I preview the webform it works fine, however when I place the view on my front page it returns 0 results.

I am thinking this is because anonymous users don't have permissions to access submissions? Which I don't particularly want them to anyways.

The field also links to the submissions page of my form, which I don't want it to do either, i just want text there. I have checked the settings and there is nothing to say that the field should link to the submissions.

Bottom line, how can I create a view or perhaps if there is a count module, that will show the number of times a particular form on my site has been submitted?

Thanks! :)

1

For removing the link all you have to do is click on REWRITE RESULTS Then click on "Rewrite the output of this field" and then check "Strip HTML tags" That should remove the link.

The easiest way to achieve the other one is a bit of a hackish solution. You need can go to webfor/views folder and look for the file webform_handler_field_submission_count.inc

with in that file check for the render function.

  function render($values) {
    global $user;

    $output = NULL;
    if ($this->count_type == 'node' && in_array($values->{$this->aliases['type']}, webform_variable_get('webform_node_types'))) {
      module_load_include('inc', 'webform', 'includes/webform.submissions');
      $node = node_load($values->{$this->aliases['nid']});
      //if (webform_results_access($node, $user)) {
        $count = webform_get_submission_count($node->nid);
        $output = l($count, "node/$node->nid/webform-results");
      /*}
      else {
        $count = webform_get_submission_count($node->nid, $user->uid);
        $output = l($count, "node/$node->nid/submissions");
      }*/
    }
    elseif ($this->count_type == 'users') {
      $output = db_select('webform_submissions')
        ->condition('uid', $values->{$this->aliases['uid']})
        ->countQuery->execute()->fetchField();
    }

    return $output;
  }

In this above code I have commented a section. You can do the same it should work now for anonymous user. As I said this is a hackish solution and wont advice to do the same. The cleaner method would be to create a custom module and add the handler you want in the custom module and use that instead.

  • Hi there! Thanks for your reply! :) Seeing as I have never created a custom module before, I think I'm going to go with hacky, haha. – LadyVicious Jan 17 '13 at 10:55
  • Good luck with that. Just take care when you update the webform module as it will over write the changes you make. – Mohammed Shameem Jan 17 '13 at 11:01
0

Webform 7.x-4.2 will have this feature built-in. If the user has access to NEITHER the list of all results NOR the list of the user's results, then a simple count of all the results will be displayed, with no link. See: https://www.drupal.org/node/2367065

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.