We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23491 ☆ A M B ☆
    • 1,056 Posts
    (Using Ditto 2.0.1 SVN)

    I have a Ditto call in the footer of the site. This footer is shown on EVERY page via the following Ditto call:

    [!Ditto? &debug=`1` &where=`parent <> 2` &tpl=`footer_tpl` &startID=`0` &depth=`2` &summarize=`all` &showInMenuOnly=`1` &seeThruUnpub=`1` &sortBy=`pagetitle` &sortDir=`ASC`!]                            
    


    The output/TPL are very simple. Nothing more than your typical footer links at the bottom of a page.

    Now, I also have an articles page (with pagination) displaying 50 articles per page... When on Page 2 or higher (anything with ?start=X where X is greater than 0) causes Ditto to display: No documents found. error. However, on Page 1 of the paginated Ditto results, the footer links are displayed as expected?

    Articles page Ditto:
    [!Ditto? &debug=`0` &tpl=`article_tpl` &startID=`2` &depth=`1` &summarize=`50` &paginate=`1` &paginateAlwaysShowLinks=`1` &showInMenuOnly=`1` &sortBy=`pagetitle` &sortDir=`ASC` !]
    


    Why does this unrelated Ditto call in my footer get impacted when on paginated results page?

    So, I turned on debugging to see what was going on, only I get the following error when I try to open the console:



    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « PHP Parse Error »

    PHP error debug
    Error: Invalid argument supplied for foreach()
    Error type/ Nr.: Warning - 2
    File: C:\www\sandbox\assets\snippets\ditto\classes\debug.class.inc.php
    Line: 135
    Line 135 source: foreach ($resource as $item) {

    Parser timing
    MySQL: 0.1409 s (38 Requests)
    PHP: 0.1556 s
    Total: 0.2965 s
      Mike Reid - www.pixelchutes.com
      MODx Ambassador / Contributor
      [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
      ________________________________
      Where every pixel matters.
      • 23491 ☆ A M B ☆
      • 1,056 Posts
      Update!

      Well, it turns out ANY ?start= param is natively picked up by Ditto. (Duh!) This is obviously by design and I think it makes sense.

      For example, if I had ?start=50 to the home page URL, NONE of the other Ditto calls work, and everything is "Not found"...

      What is the best way around this issue, where you have multiple Ditto calls where one requires pagination?

      In the meantime, I am reviewing:

      http://modxcms.com/forums/index.php/topic,12765.msg84806.html#msg84806
      http://modxcms.com/forums/index.php?PHPSESSID=da0a8f8822375fa5ae6461968b1ba67d&topic=6806.5
        Mike Reid - www.pixelchutes.com
        MODx Ambassador / Contributor
        [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
        ________________________________
        Where every pixel matters.
        • 23491 ☆ A M B ☆
        • 1,056 Posts
        Solved!

        Awesome! Was as simple as adding &id=`unique_name` to my PAGINATED Ditto snippet call.

        Then, for the pagination TPLs, I had to convert:
        <div id="ditto_pages">[+previous+] [+pages+] [+next+]</div>
        <strong>[+total+]</strong> Total Articles<br/>
        </div>

        to this:
        <div id="ditto_pages">[+articles_previous+] [+articles_pages+] [+articles_next+]</div>
        <strong>[+articles_total+]</strong> Total Articles<br/>
        </div>

        where &id=`articles` is my unique id...
        Thank you to everybody who has contributed to this great solution, and Mark for making it possible.

        Cheers! (Careful, Green Beer can stain...)
          Mike Reid - www.pixelchutes.com
          MODx Ambassador / Contributor
          [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
          ________________________________
          Where every pixel matters.