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

    This database query results in almost 20K rows of data.

    Such data has no use for the visitor and search engines, and places an unnecessary load on the database and web servers.

    Instead, I would like to display only 200 rows on this page and subsequent pages of up to 200 rows each.

    The pagination controls must include page numbers (and not only prev and next) for the search engines sake.

    What MODx extra can I use to achieve this goal? I’ve been searching the Extra repository extensively and couldn’t find a solution by myself.

    Thanks,
    Shlomo Tommer
      Cheers,
      Shlomo Tommer
      • 33337
      • 3,975 Posts
      What are you using for the listing?
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 27072
        • 76 Posts
        Right now I am executing my own script: $modx->db->query() and $modx->db->getRow()
          Cheers,
          Shlomo Tommer
          • 26931
          • 2,314 Posts
          The pagination controls must include page numbers (and not only prev and next) for the search engines sake.

          What MODx extra can I use to achieve this goal? I’ve been searching the Extra repository extensively and couldn’t find a solution by myself.
          loopDbChunk maybe? http://modxcms.com/forums/index.php/topic,14654.0.html
            • 18913
            • 654 Posts
            Go with sharkbait’s rec on this one ...

            I used loopdbchunk to accomplish this sort of thing for a member listing. I modified the loopdbchunk snippet to be able to pass a URL parameter to the pagination routine specifying the listing range. I also modified the pagination routine to output first, last, next, previous (as I recall). Also, the loopdbchunk itself got some work done on it, as I wanted to be able to use it for either a MODx table or an external MySQL database. Finally, I created a wrapper snippet which parses the URL line, sets up an appropriate query and calls loopdbchunk. There are probably less kludgy ways of accomplishing the same thing, but it worked for me.

            Matt

              • 27072
              • 76 Posts
              Thank you, sharkbait and mconsidine, for your guidance.

              loopDbChunk is indeed a cool tool and I have started using it.

              My main problem with the tool is the page numbers. If you want page numbers as part of the pagination controls, you are required to set a fix number of pages to be listed, with no consideration to the actual number of rows there are. Thus, it is possible to render links to 10 page numbers of 100 rows each when there are actually only 30 records. Any suggestions?

              One more nice2have feature may be to define another built-in placeholder (like the ’lo_ord’ counter) that returns the count of records in the dataset.

              Thanks again
                Cheers,
                Shlomo Tommer
                • 4172
                • 5,888 Posts
                you can add this line:

                		$output .= $this->footer;
                
                      $this->perPage=$numRows<30?0:$this->perPage;//<- add this line for your special task
                
                      if($this->perPage > 0) 
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!