Problem/Motivation

Currently, pagination is done counting the rows in the result set retrieved from the JSON file. Several services provides JSON endpoint for their data with support for pagination in the query string of the JSON URI. These service usually provide a total items count as part of their response.

Proposed resolution

Add the following query options:

  • Rows count apart
  • Enable support of the pagination query parameter
  • Limit query string parameter name
  • Offet query string parameter name

Comments

pbuyle’s picture

The attached patch implement the suggested solution.

The row count extraction is done in views_json_query_plugin_query_json::parse(). Injection of the pagination query string parameters is done in views_json_query_plugin_query_json::build().

pbuyle’s picture

Status: Active » Needs review
pbuyle’s picture

StatusFileSize
new5.9 KB

Rework of the patch to remove an extra '/' that was added between the host and the path componenet of the JSON file URL.

marcofernandes’s picture

I'll try today to apply this and others patches on other issues to dev branch.
Thanks Pierre for the great work :).

3eidoz’s picture

when i try to apply patch, tell me The patch cannot be applied in the selected context.

can help plz

pbuyle’s picture

Status: Needs review » Needs work
+++ b/views_json_query_plugin_query_json.inc
@@ -33,8 +33,20 @@ class views_json_query_plugin_query_json extends views_plugin_query {
+    $view->query->options['json_file'] = "{$parsed['scheme']}://{$parsed['host']}{$parsed['path']}?" . drupal_http_build_query($query_string);

As reported by @tariqinam this does not cover everything that parse_url() could produce. The http_build_url function could be used but it requires a PECL extensions. There is a non-PECL implementation available at https://github.com/jakeasmith/http_build_url that could be embedded in the module.

discipolo’s picture

StatusFileSize
new5.59 KB

rerolling anyway

marcofernandes’s picture

Status: Needs work » Fixed

Also merged #2250191 latest patch. Setting this to fixed.

Status: Fixed » Closed (fixed)

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