We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34002
    • 1 Posts
    Greetings everyone.

    I'm grabbing JSON data then parsing it to a modx chunk like so:

    $url = "//myjsonurl";
    $json = file_get_contents($url);
    $data = json_decode($json, TRUE);
    
    foreach($data['objects'] as $item){
    
    $output = $modx->getChunk('pets.list.json',array(
      'id' => $item['id'],
      'mainimage_file_name' => $item['image'],
      'name' => $item['name'],
      'status' => $item['status'],
      'breed' => $item['breed'],
      'gender' => $item['gender'],
      'birthday' => $item['birthday'],
     
       
    ));
    print $output;
    
    }


    This works fine - but I need to add pagination ( paginate the results ). Because this is not a xpdo query, I figure I can't use getPage - and will have to figure it out some other way - like using Jquery or just some standard PHP way of doing it.

    Thank you in advanced : )
      • 4172
      • 5,888 Posts
      perhaps you can try the getImageList-snippet from MIGX

      https://github.com/Bruno17/MIGX/blob/master/core/components/migx/elements/snippets/snippet.getImagelist.php

      It can do pagination together with getPage on JSON-data
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!