Comments

gbyte’s picture

It appears the problem with pagination output is that Views Merge Rows uses the views_pre_render hook to only change the output of the query that already ran. Views doesn't see the change and still sees the original number of rows.
I don't think there is any way of changing what pagination sees apart of changing this module to using views_pre_build.
Please correct me if I'm wrong.

Anyone looking for similar functionality which changes the query may look into this issue. Though the patch didn't work for my specific case, it may work for you.

gbyte’s picture

Assigned: Unassigned » gbyte

Will be finishing a quick patch for this soon.

gbyte’s picture

This patch allows for proper pagination with this module. It uses views_pre_build() to remove the pager (thus removing the LIMIT part of the SQL query).
Though it may slightly slow down queries returning lots of data, it's needed because views_merge_rows only merges the rows in hook_views_pre_render(). There the pager is reset according to the number of merged rows.
It's by no means a perfect solution but it appears to be the only one possible without rewriting the module.
Don't forget to clean the cache.

gbyte’s picture

Status: Active » Needs review
gbyte’s picture

StatusFileSize
new3.47 KB

Fixed a little bug from the previous version of the patch in views_pre_build and changed the warning that warns from using the pager.

neeravbm’s picture

There is a bug in the patch. I added second view mode for Data Export and changed the pager limit. This patch still uses the pager limit of the first view mode. The culprit is the line:

$items_per_page = (int)$view->display[$view->tag]->display_options['pager']['options']['items_per_page'];

I have changed it to the following:

$items_per_page = (int)$view->display[$view->current_display]->display_options['pager']['options']['items_per_page'];

Patch is attached.

neeravbm’s picture

Patch #6 doesn't work. Here is the updated patch if the current display has different number of items in the pager or has no pager.

scottrigby’s picture

Component: Miscellaneous » Code
Assigned: gbyte » Unassigned
Status: Needs review » Reviewed & tested by the community

@neeravbm #7++

nithinkolekar’s picture

@
I am having issue #2502879: support views merge rows iterating though views merged rows with https://www.drupal.org/project/views_rules. From your observations

It appears the problem with pagination output is that Views Merge Rows uses the views_pre_render hook to only change the output of the query that already ran. Views doesn't see the change and still sees the original number of rows.

It seems rules still getting actual rows instead of merged single row with this patch applied.

use case:
task: send notification through sms
setup: build views of phoneno ,Grouping field: Message(not aggregation) exclude from display
sample output:

row1|123456789,456789870
row2|145869872,241569878
gbyte’s picture

@nithinkolekar

It seems rules still getting actual rows instead of merged single row with this patch applied.

This will not change as this module only changes the output of a view that already ran. Views rules however communicates with views through its results. A module is needed that will do what this module does by altering the views sql queries. Big part of that is group concat I believe.

nishant.bhorodia’s picture

Hello @neeravbm

Thank you for the patch. it works perfect.

Just a few things though:

1. I added fetching "items_per_page" from url as well.
2. Total number of results was the same as "items_per_page". so for example, if there are 10 results and items_per_page = 2 then the total_rows = 2 as well. In above example, the total_rows needs to be 10 so fixed that.

Thanks again !!

nishant.bhorodia’s picture

StatusFileSize
new6.12 KB

Sorry, first time submitting patch.
Had wrong diff lines on top. made the correction.
Thanks !!

giorgosk’s picture

#12 does not apply but probably works

placed patch from #12 in module directory and did git apply -v [patchname].patch but patch did no apply with following error messages

Checking patch views_merge_rows.module...
error: while searching for:
  $table = theme('table', array('header' => $header, 'rows' => $rows));

  $form['table_fieldset'] = array(
    '#title' => t('Configure merging options for the fields'),
    '#type' => 'fieldset',
    '#dependency' => array('edit-options-merge-rows' => array(1)),

error: patch failed: views_merge_rows.module:49
error: views_merge_rows.module: patch does not apply
Checking patch views_merge_rows_plugin_display_extender.inc...

Applying the patch by hand and clearing cache seems to work

#7 patch applies and seems to work

I also applied #7 patch which applied without me having to do it manually
this also seems to work so I am going to have to go with #7 patch

applied patch to latest DEV version (as its usually the case)

please commit #7

dgagne’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

fadi.assaad’s picture

Same patch for 1.0-rc1

gagandeep_katare’s picture

I have used #16 patch for 1.0-rc1.
It is working for me if number of result are less then 500,But it is not working if number of result are more then 500 and display White blank screen.