We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    Perhaps I am doing something wrong, but the pagination output of this Ditto call
    <p>[[Ditto? &parents=`41` &tpl=`news_tpl` &display=`2` &paginate=`1` &paginateAlwaysShowLinks=`0`]]
    </p>
    <p>[+previous+] [+pages+] [+next+]</p>
    


    shows the number "1" when there is only one page of results. That’s perfectly correct, but if there’s only one page of results I don’t want to show the page number. Can anyone point out how that can be supressed? The call is a cached call on an uncached page because of Phx being enabled ...

    Thanks in advance. I did check the archives and some "help" pages, but didn’t find any obvious answer. And goofing with the parameters hasn’t been successful either. Still, I could have missed something obvious and if that’s the case I apologize.
    Matt
      • 15175
      • 116 Posts
      I use PHx to remove it:

      [+previous+] [+phx:if=`[+totalPages+]`:is=`1`:then=``:else=`[+pages+]`+] [+next+]

      There maybe another method, but it does the job.

        • 18913
        • 654 Posts
        Okay, I can work with that. Thanks!
        Matt
          • 18913
          • 654 Posts
          I understand the logic behind the above solution to the question. But it would seem a more elegant solution would be to patch Ditto to not output a page number if there is only one page of results (this could be a flag that gets passed to it).

          I don’t have much familiarity with the Ditto code. Is there anyone who is familiar with it who could just point me to the area where I would need to add logic? If someone has a patch available that would be great to see. But I’m not asking for any code to be written for me. Unless, of course, someone really has nothing better to do ... smiley

          Thanks in advance,
          Matt
          (And, yes, I did try to search the archives/Google for this answer)
            • 18913
            • 654 Posts
            The solution I *think* works is to wrap line 960 of the Ditto snippet in a conditional like this

            if ($total > $display){  //MattC
                    $tplPaginateCurrentPage = isset($tplPaginateCurrentPage)? $ditto->template->fetch($tplPaginateCurrentPage) : "<span class='ditto_currentpage'>[+page+]</span>";
            }


            If anyone sees a problem with this approach and could point it out, I’d be appreciative.
            Matt