We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12390
    • 39 Posts
    Hi,

    If you’re paginating say 10 per page, is it possible to hide the pagination block if there is only one page to show? (i.e. there are 10 or less documents).


    Thanks
      • 10449
      • 956 Posts
      This was discussed earlier already. Seems like it’s planned for a future release: http://mirror3.cvsdude.com/trac/ditto/codebase/ticket/79

      Perhaps this workaround will work: http://modxcms.com/forums/index.php/topic,12262.msg172354.html#msg172354
      (hiding it via JS)
        • 12390
        • 39 Posts
        Cheers
          • 7231
          • 4,205 Posts
          I have done this with a wrapper snippet using the [+totalpages+] output as the trigger. Might be able to use PHx for this as well.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 4542
            • 7 Posts
            You can go in and edit the ditto snippet to accomplish this...
            (granted, my php might not be the prettiest)

            Open it for editing and scroll down to line 975 or so.

            find a line that looks like this:
            $ditto->paginate($start, $stop, $total, $display, $tplPaginateNext, $tplPaginatePrevious, $tplPaginateNextOff, $tplPaginatePreviousOff, $tplPaginatePage, $tplPaginateCurrentPage, $paginateAlwaysShowLinks, $paginateSplitterCharacter);


            Change it to this:
             if($count>$display){
                    $ditto->paginate($start, $stop, $total, $display, $tplPaginateNext, $tplPaginatePrevious, $tplPaginateNextOff, $tplPaginatePreviousOff, $tplPaginatePage, $tplPaginateCurrentPage, $paginateAlwaysShowLinks, $paginateSplitterCharacter);
                    }else{
                    $ditto->paginate($start, $stop, $total, $display, "", "", $tplPaginateNextOff, $tplPaginatePreviousOff, "", "", $paginateAlwaysShowLinks, $paginateSplitterCharacter);
                    }


            Note, this removes the page numbers at the bottom but leaves the "Showing 1 - 3 of 3 Items" or whatever you’ve put in for your text.

            It’s a hack, and it still creates the ditto_pages div that contains the pagination, but it removes the data from the function so there are no pages displayed. It just compares the $count variable (the number of documents retrieved minus offset) to the $display variable (user-set number of docs to display per page).

            HTH