Project:Webform Report
Version:6.x-1.11
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I am having a problem with pagination with the webform report. The report works fine until I reached 21 lines. I get the pagination links for the next page. However, when clicked to go to page 2 or last page I go to the main page of the site. However, if I enter the following:

http://myurl?q=node/3/sort=desc&order=Status&page=2

I can get the next page. Since I am not running clean urls could this be the problem? Because the next link only has the sort=desc&order=Status&page=2 part of the url. Any ideas?

Searching the forums I only found one other mention of this problem. So that is why I am placing this here.

Thanks

Comments

#1

I was able to correct the problem that I was having with the pagination. I found that if I modified the webform_report.inc file with the changes shown below I was able to get the pagination to work. Now I don't know if this the correct way this include file should be modified, but it works for me.

Looking at the code below:

I modified the line from:

     $output .= '<a class="pager-first active" title="' . t('Go to first page') . '" href="?sort=' . $_GET['sort'] . '&order=' . $_GET['order'] . '&page=1">' . t('« first') .'</a>';

to:
    $output .= '<a class="pager-first active" title="' . t('Go to first page') . '" href="?q=node/' . $node->nid . '/?sort=' . $_GET['sort'] . '&order=' . $_GET['order'] . '&page=1">' . t('« first') .'</a>';

I modified each instance of this line in the file to include the q=node/' . $node->nid . '/ part.

Hopefully, this might help someone else. I have attached the entire file to this comment.

AttachmentSize
webform_report.txt 14.95 KB

#2

Status:active» postponed (maintainer needs more info)

See if the problem still exists in the current version - the pagination funcation has been reworked.

#3

I use webform_report-6.x-1.10 which creates a very nice looking report form right on the website that can automatically be sorted by ANY field. The librarians like to check it every day. I just launched our website and this is the first year I've used Drupal, so I'm a Newbie. The webform report module under Report Criteria / Results Per Page does not give me an option to select more than 100 [s-i-g-h]. There's no All or Unlimited there. So that's why I think I might need to edit some code to add pagination, unless someone has another suggestion. I have attached the pagination portion or our webform_report.inc file if anyone cares to take a look at it.

I can always go back and download the records into Excel from the database using the webform module, but would like to avoid it if at all possible. The librarians access and edit the entries continuously and they have contests and give-aways during various date spans (ex. May 10 through May 25) so they may need copies of records at any given time.

Thanks!
cburn

/**
* Paginate the webform report.
*
* @return a themed table with page links
*/
function _webform_report_pager($fields, $values, $node) {
// For backward compatibility to earlier versions.
if (!$node->results_per_page) {
$results_per_page = 20;
}
else {
$results_per_page = $node->results_per_page;
}
// Add the css file for form display.
drupal_add_css(drupal_get_path('module', 'webform_report') . '/webform_report.css');

// Break the array into chunks for pagination.
$pages = array_chunk($values, $results_per_page, TRUE);

// Grab the 'page' query parameter.
// Taken from pager_query() in pager.inc
$page = isset($_GET['page']) ? $_GET['page'] : '';

// Convert comma-separated $page to an array, used by other functions.
// Taken from pager_query() in pager.inc
$pager_page_array = explode(',', $page);

// format the table with the current page
if ($page == '') $page = 0;
$output = theme_table($fields, $pages[$page], array('class' => 'webform_report'));

// Put some magic in the two global variables
// Based on code in pager_query() in pager.inc
$pager_total[0] = count($pages);
$pager_page_array[0] =
max(0, min(
(int)$pager_page_array[0],
((int)$pager_total[0]) - 1)
);

// Add the pager to the output.
$output .= theme('pager', NULL, $results_per_page, 0);

return $output;
}

?>

#4

subscribe

#5

To address the problem cburn brings up, I created a pair of patches to add an 'All' option for a report.

I patched webform_report v6.x-1.11

The patch to webform_report.module uses 0 as a placeholder for 'All' in the results. There also a place that 0 needs to be recognized as a valid option.

The patch to webfrom_report.inc skips the array_chunk call if the report should show all and instead dumps the results into a nested array.

AttachmentSize
webform_report.inc_.patch 976 bytes
webform_report.module.patch 1.18 KB

#6

Version:6.x-1.8» 6.x-1.11
Status:postponed (maintainer needs more info)» needs review

Cool. Let's see what the maintainer thinks.

#7

I am really not sure if it breaks the backward compatibility that is discussed. If that is the case, maybe a database update function is in order. This is a pretty neat module.

#8

Status:needs review» reviewed & tested by the community

The patches work for me - thanks very much for sharing them. I will commit to CVS shortly.

#9

Status:reviewed & tested by the community» needs review

I have one reservation about the above patch - I would like to retain the default of 20 items per page when creating new webform reports.

In webform_report.module:

if (!empty($node->results_per_page) || $node->results_per_page==0) {
  $default = $node->results_per_page;
}
else {
  $default = 20;
}

was updated to:

if (arg(2) != 'add' && (!empty($node->results_per_page) || $node->results_per_page==0)) {
  $default = $node->results_per_page;
}
else {
  $default = 20;
}

I've attached an updated patch. Does anyone object to this?

AttachmentSize
487414.patch 2.58 KB

#10

The default of 20 is fine as long as the pagination works and will advance to the next record on the next page and to the end of records. I'm looking to have approximately 900 kids to register for Summer Reading before June 1st. Sorry, I'm not very well versed in the code. Thanks.

#11

Status:needs review» fixed

No further feedback - committed patch to CVS

#12

Thanks! Since I am very new to Drupal, would you be so kind to point me to some pertinent instructions on how to apply this patch. We are using ANHosting and are running on Linux using Apache.

#13

There is an article on applying patches on the Drupal site here. You will have to go to the webform_report directory on your server and run the patch program with the patch file as input. I'm not sure what sort of access you have with ANHosting...

You can also wait a bit and install the development release of this module, which should include the patch - it should build later this evening and have today's date. That is the only patch that has been applied to the CVS, so you shouldn't have any problems with it.

Hope this helps.

#14

Good catch. I definitely didn't test it with creating a new report.

#15

I installed webform_report-6.x-1.x-dev 5-22-10 and the pagination works beautifully! Thanks @jimbullington and @calebtr for working on this so promptly. Ya got me covered before June 1st! It's a great module. (And I read where more improvements may be coming with possible co-maintainers of the module.)

#16

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.