We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29877
    • 35 Posts
    I have a specific objective that I’m trying to accomplish and I have been unsuccessful thus far.

    The premise of this is to display a list of events using Ditto. I am including pagination into this, breaking the events down to multiple pages. However the twist is that I’ve setup the Ditto with some tricky filters, one is to include ONLY events that are NOT in the past. All of this works great, except when all of the events have past. I am then left with the message "No documents found", as well as pagination styling when there are no additional pages. I realize that I can easily change the message using the "&noResults" parameter, but that does not address that the pagination styling remains.

    What I attempted to do was use PHx with an If/Else statement to display or NOT display the pagination. I found that this did not go as planned. Infact, I discovered that when I installed PHx and while it was enabled, my standard pagination broke before I even tried to use a PHx statement on my ditto page. I don’t know why that is, or what that is indicating.

    For reference, here is the Ditto call that I’m using to pull up the list of events:

    [!Ditto? &parents=`1097` &orderBy=`eventstartdate ASC` &display=`6` &paginate=`1` &paginateAlwaysShowLinks=`1` &tpl=`tpl_eventlisting` &filter=`event_country,United Kingdom|eventenddate,@EVAL return strtotime(now);,6`!]
    


    As you can see I’m using an @EVAL binding to filter out the events that have already passed.

    The PHx statement that I was attempting to use is:

    [+phx:if=`[+total+]`:is!=`0`:then=`{{pagination}}`:else=``+]
    


    With pagination working "[+total+]" is equal to the total number of documents being display. In this example, it would be zero. My thought here is to check that number and display the pagination code (via a chunk) when the condition is met. Else, display nothing.

    Also for reference, my pagination chunk:

    <div class="ditto_paging">
      <div id="ditto_counts">Displaing page <strong>[+currentPage+]</strong> of <strong>[+totalPages+]</strong></div>
      <div id="ditto_pages">[+previous+] [+pages+] [+next+]</div>
    </div>
    


    A problem, as I mentioned earlier. When PHx is enabled in the manager, it breaks the pagination before I even attempt to incorporate the PHx statement I provided above.

    I am not sure where to go from here. Help on this would be wonderful. Thank you.
      • 20413
      • 2,877 Posts
      Split Pagingation for Ditto with PHx installed: http://modxcms.com/forums/index.php/topic,34522.msg210035.html#msg210035

      Option to turn off PHx for certain templates: http://modxcms.com/forums/index.php/topic,33316.msg238461.html#msg238461
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 29877
        • 35 Posts
        Quote from: mrhaw at Mar 11, 2010, 03:08 PM

        Split Pagingation for Ditto with PHx installed: http://modxcms.com/forums/index.php/topic,34522.msg210035.html#msg210035

        Option to turn off PHx for certain templates: http://modxcms.com/forums/index.php/topic,33316.msg238461.html#msg238461

        I am not sure how either of these apply to my situation. I did however take the updated code for PHx (2.1.4) and update what I already had (2.1.3). That however did not make any difference in my pagination being broke with just enabling the PHx plugin.

        With PHx plugin DISABLED and documents available to display, I see:

        "Displaing page 1 of 2"

        With PHx plugin ENABLED and documents available to display, I see:

        "Displaing page of"

        It doesn’t acknowledge the "[+currentPage+]" and "[+totalPages+]" in the pagination.
          • 20413
          • 2,877 Posts
          I automatically spit that out in every Ditto and PHx thread.

          Try
          [+phx:if=`[+total+]`:ne=`0`:then=`{{pagination}}`:else=``+]

          This should work as well
          [+total:ne=`0`:then=`{{pagination}}`:else=``+]

            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 36416
            • 589 Posts
            Quote from: thomasgrant at Mar 11, 2010, 03:58 PM

            Quote from: mrhaw at Mar 11, 2010, 03:08 PM

            Split Pagingation for Ditto with PHx installed: http://modxcms.com/forums/index.php/topic,34522.msg210035.html#msg210035
            I am not sure how either of these apply to my situation.

            Read the first link again... and adjust the code at the end of DittoPageSplit with your conditional display logic, i.e:
            <?php
            if ($output && $total > 0) { ...
            
              • 29877
              • 35 Posts
              I appreciate the replies and the enthusiasm from the both of you so far. I will keep working on this. But I’m still having an issue before I get to the conditional piece of PHx, as I mentioned in post #3.

              With PHx enabled, ditto pagination breaks. Unless I entirely misunderstood your reference to the "Split Pagingation for Ditto with PHx installed" link that you provided. Is that to fix the break?

              UPDATE:

              Through further reading, I found the "workaround" for the pagination breaking in this thread. I will now work on my conditional operations with PHx and see what I can come up with.
                • 29877
                • 35 Posts
                Quote from: mrhaw at Mar 11, 2010, 06:14 PM

                I automatically spit that out in every Ditto and PHx thread.

                Try
                [+phx:if=`[+total+]`:ne=`0`:then=`{{pagination}}`:else=``+]


                I did get this to work wonderfully after I solved the pagination breaking problem with that "workaround" that I mentioned above.

                So far, so good. I think I’m on my way to getting what I want here. Thank you for your assistance.