We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1828
    • 137 Posts
    I’m seeing the following error when using a ditto call in a folder with no items in it. This situation occurs because I am configuring the site in preparation for the site owner to start posting articles in the folder. Is there any way to prevent this?

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

    PHP error debug
    Error: array_values() [function.array-values]: The argument should be an array
    Error type/ Nr.: Warning - 2
    File: ...public_html/manager/includes/document.parser.class.inc.php(705) : eval()’d code
    Line: 372

    Parser timing
    MySQL: 0.0038 s s (21 Requests)
    PHP: 0.0553 s s
    Total: 0.0591 s s
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Well, for a quick band-aid, I would create a dummy article, if for no other purpose than as an example for your client. He can easily enough edit it to make his first article, and just duplicate it for subsequent articles.

      Alternatively, try adding this line just before the call to array_values(), around line 372 in the snippet code:
      if(empty($resource)) {return $emptyText."\n"; } // add this line
      $resource = array_values($resource);
      

      I haven’t tested it, but it should do the job.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 18397
        • 3,250 Posts
        From the main Ditto thread:

        Quote from: tillda at Jul 10, 2006, 10:17 AM

        I had troubles running Ditto Version: 1.0.2, there is:

        if (count($resource) < 1) { return $emptyText."\n"; }

        but this count() returns 1 of $resource is false, so I’ve changed it to:

        if ((count($resource) < 1) || (!$resource)) { return $emptyText."\n"; }

        I’m running PHP 5.x (5.1.2 afaik), so there may have been some minor changes...

        This is fixed in the next version, coming soon!
          • 1828
          • 137 Posts
          Thanks, have fixed!