We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    this should work with friendlyUrls on:

    download that package: http://www.aplusdesign.com.au/misc/pagination/easyajaxpagination_mootools.zip

    upload that files to your modx-installation in /assets/components/ajaxgetpage/js
    All files direct in that folder. No files on a subfolder!

    create snippet ajaxGetPage:

    <?php
    
    if ($ajax=='1'){
    $loadPage 		= $_REQUEST['page'];
    $current 		= $_REQUEST['current'];
    
    $page=$modx->runSnippet('getPage',$scriptProperties);
    $pagination='<ul>'.$modx->getPlaceholder('page.nav').'</ul>';	
    
    $direction = 'left';
    if ($current < $loadPage) {
    	$direction = 'right';
    }
    
    $paginatedStyle = 'style="left:'.($direction == 'left' ? '-750px' : '750px').';"';
    
    
    // The paginated content HTML slide
    $page = '<div class="paginated" id="" '.$paginatedStyle.'>'.$page.'</div>';
    
    return json_encode(array( 'pagination' => $pagination, 'page' => $page, 'current' => $loadPage ));
    	
    }
    
    
    $modx->regClientCss($modx->getOption('assets_url').'components/ajaxgetpage/js/pagination.css');
    $modx->regClientStartupScript($modx->getOption('assets_url').'components/ajaxgetpage/js/mootools-1.2.3-com.js');
    $modx->regClientStartupScript($modx->getOption('assets_url').'components/ajaxgetpage/js/pagination.js');
    $url=$modx->makeUrl($ajaxpage);
    $js="
    <script>
    window.addEvent('domready', function() {
    	// URL, {Options}
    	new Paginator('{$url}',{qString : '?page='});
    });
    </script>
    ";
    $modx->regClientStartupHTMLBlock($js);
    
    return'';


    create a new resource in your resource-tree with blank template.
    This page is your ajax-processor, which is called from your front-page and sends back the pagination and content to your front-page later.
    As content put a snippet-call with something like that:
    [[!ajaxGetPage? 
    &ajax=`1`
    &sortBy=`id`
       &elementClass=`modSnippet`
       &element=`getResources`
       &limit=`4`
       &pageVarKey=`page`
       &tpl=`adresse`
       &parents=`11`
       &includeTVs=`1`
       &processTVs=`1`
    
    ]]
    


    on your page where you want to have the pagination put the following into the content.
    Don’t forget to fill &ajaxpage with your id of the new created ajax-resource.
    This loads the javascripts and CSS to your head.
    The javascript loads then the first page from your ajax-page.
    The nice thing: You can call that page with yourURL#page=10 and it loads the page 10.
    Also browser-back-button and that should work with that code.

    [[!ajaxGetPage? &ajaxpage=`251`]]
    
    	<!-- Begin Pagination code -->
    	<div id="pagination_controls">
            <div id="pagination_control_wrapper">
            </div>
            </div>    
    	<div id="pagination_container">
           <div id="pagination_content_wrapper">
           </div>
        </div>
        <!-- End Pagination code -->


    if you want your page works also with js-off just insert your normal getPage-call and pagination-placeholder in above divs.



      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 22318
      • 8 Posts
      Thank you Bruno

      I have done everything as you said. What I can not understand is "create an ajax-resource with blank template and call like that:".
      Where should I create this. I am using Modx Revolution
        • 4172
        • 5,888 Posts
        in your resource-tree create a new page.
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 16545
          • 358 Posts
          Bruno: will your snippet work on Evo?
            • 4172
            • 5,888 Posts
            Quote from: labasus at Dec 01, 2010, 09:00 AM

            Bruno: will your snippet work on Evo?

            No, not as it is, it works together with getPage.
            But I think you can do something similiar with Ditto and its pagination.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 14859
              • 1 Posts
              Assuming that I would like to use the JQuery framework, as opposed to the Moo Tools framework, the replacement for the Javascript assigned to the $js variable would be as follows correct?
              <script>
              $(document).ready(function() {
                new Paginator('{$url}',{qString : '?page='});
              });
              </script>
              
                • 21671
                • 244 Posts
                Hi All,

                Sharkbait just forwarded me to this forum topic. Very interesting solution for revo. I want to use the infinitescroll jQuery plugin with ditto in Evolution. Bruno, do you have any idea how to implement this to work.

                Many Thanks,

                Noah
                  • 26931
                  • 2,314 Posts
                  Sharkbait just forwarded me to this forum topic. Very interesting solution for revo. I want to use the infinitescroll jQuery plugin with ditto in Evolution. Bruno, do you have any idea how to implement this to work.
                  something like this e.g.
                  http://www.infinite-scroll.com/infinite-scroll-jquery-plugin/
                  https://github.com/paulirish/infinite-scroll
                  rolleyes
                    • 59
                    • 10 Posts
                    Hi thank you very much for sharing this. I implemented it using jQuery and it works fine, but I am having the following problem:

                    On the page where I have the [[!ajaxGetPage]] call I am using another snippet (just created a simple get/set snippet) to set a session variable that contains the &parents value.

                    I modified the ajaxGetPage to grab this value and overwrite the $scriptProperties array.

                    It works fine the first time, but the $parents value I am passing to the ajaxGetPage snippet is cached and as a result returns the same paginated result each time. All of my snippet calls are uncached and I set the ajax page to uncached testin git, but it did not work.

                    I have the [[!ajaxGetPage]] placed into the page template, and the idea I had was to use [[*id]] and UltimateParent to paginate results for the particular folder the user is browsing.


                    Update: It seems that some things are still being cached. Here is what is in the cache: /cache/web/resources/13/1/c4ca4238a0b923820dcc509a6f75849b.cache.php. 13 is my ajax processor resource, and 1 is the paginated result that was loaded (page 1).

                    As soon as I delete the cache file I can load in a different page again.

                    Is there a way to stop MODX from caching this?

                    Update 02: a little bit of a hack I know, but I managed to fix this problem using-
                    $paths = array('web/resources/13/');
                    $modx->cacheManager->clearCache($paths);
                    






                      • 19463
                      • 4 Posts
                      What jQuery paginator have you use, could you share your jQuery related changes?