We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42428
    • 6 Posts
    I'm using getPage to paginate some MIGX data. It's working quite well, in fact I'm really impressed with how easy it was to set up.

    I am using it to display a list of projects, and I filter those projects by their location. When I apply the filter, getPage will only show the results that match the filter, as expected. However, the page navigation shows the number of pages for ALL results.

    For example, I have 9 projects in MIGX. I select a filter with 3 projects. getPage displays the first two projects, and if I hit >>, it displays the third and final project. However, the navigation displays "First << 1 2 3 4 5 >> Last". Clicking on a number beyond page 2 results in an empty result set.

    Here's my getPage Call:
      [[!getPage? &elementClass=`modSnippet` &element=`getImageList` &tvname=`projectMIGX` &tpl=`tplProjectList` &limit=`2` &where=`[[!getProjectLocation]]` ]]


    and here is the getProjectLocation snippet:

    <?php
    $location = '';
    if(isset($_GET['location']))
    {
    	$location = '{"projectLocation:=":"' .$_GET['location'] .'"}';
    }
    return $location;


    I think I can successfully switch to getResources as opposed to getImageList if that would help with minimal effort. But given the amount of functionality that is working with getImageList, I'm inclined to think it's getPage that isn't playing nice.

    I'm also not sure that using a snippet to drop in the filter is the best way to handle this, and I am open to suggestions.

    Hopefully someone has seen this behavior before!

    Thanks,
    Chris

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      this sounds like there is a bug in getImageList

      try to change this lines:

      $items = $modx->fromJSON($outputvalue);
      $modx->setPlaceholder($totalVar, count($items));
      
      // where filter
      if (is_array($where) && count($where) > 0) {
          $items = $migx->filterItems($where, $items);
      }
      


      to:

      $items = $modx->fromJSON($outputvalue);
      // where filter
      if (is_array($where) && count($where) > 0) {
          $items = $migx->filterItems($where, $items);
      }
      $modx->setPlaceholder($totalVar, count($items));
      
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 42428
        • 6 Posts
        Hi Bruno!

        Thanks for the prompt (And Correct!) reply. I've modified getImageList and it now works perfectly. I really appreciate the effort you and others have put into the plugins for MODX, I've never had as easy a time building a site as I have using MODX for the first time on this site.

        You guys are great!

        I don't see a github for getImageList, is there somewhere I can create a bug to help with tracking?

        Thanks,
        - Chris
          • 4172
          • 5,888 Posts
          Hi Chris,

          there is https://github.com/Bruno17/MIGX

          I will commit this little fix together with some others soon.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!