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

    I want to create a chunk with the basic Ditto call so I don’t have to go through each document and change Ditto parameters when I want something different.
    So I thought to create a chunk and call Ditto every time for the current document ID (identical to the FormBlogComments chunk). The problem is I always get a MODx Parse Error sad

    My chunk code is:
    [!Ditto? &tpl=`DittoTemplate` &startID=`[~[*id*]~]` &summarize=`10` &descendentDepth=`0` &multiLevel=`0` &paginate=`1` &showPublishedOnly=`1` &trunLen=`500` &commentsChunk=`FormBlogComments`!]


    I’ve tried also with [~id~] but no luck.
    Can anyone help me please? Do I have to create a snippet for this Ditto call?

    Thank you very much!
    Boby
      ...my Photo Gallery on Flickr...
      • 10487 MODX Staff
      • 1,535 Posts
      Boby, any chance you could post the parse error? Might help narrowing down the issue.
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 3763
        • 155 Posts
        Quote from: garryn at Jul 14, 2006, 06:59 PM

        Boby, any chance you could post the parse error? Might help narrowing down the issue.
        Yes, sure smiley

        « MODx Parse Error »
        MODx encountered the following error while attempting to parse the requested resource:
        « PHP Parse Error »
         
        PHP error debug
          Error: 	array_values(): The argument should be an array	 
          Error type/ Nr.: 	Warning - 2	 
          File: 	/home/jail/home/www/htdocs/www.frozenminds.com/manager/includes/document.parser.class.inc.php(707) : eval()'d code	 
          Line: 	372	 
         
        Parser timing
          MySQL: 	0.0052 s s	(7 Requests)
          PHP: 	0.0845 s s	 
          Total: 	0.0898 s s


        I just realized, when I call [~[*id*]~] it gives me the document alias.suffix (mypage.html) and that is probably causing the error. Can I somehow get the numeric ID of current browsing document and not the alias?

        And BTW, I’m using MODx 0.9.2.1 and Ditto 1.0.2 smiley

        Thanks, Boby.
          ...my Photo Gallery on Flickr...
          • 10487 MODX Staff
          • 1,535 Posts
          I just realized, when I call [~[*id*]~] it gives me the document alias.suffix (mypage.html) and that is probably causing the error. Can I somehow get the numeric ID of current browsing document and not the alias?
          You may well be right. To get just the ID, use: [*id*]

          Try that and see if it works.
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 3763
            • 155 Posts
            I’ve done that now and tested, it really get’s the numeric ID. However I also tried to call Ditto with an available ID:
            [!Ditto? &startID=`39` ... !]


            And I get the same error like above sad
            Could it be actually a problem with Ditto?

            Ok, and just to make sure I call the chunk correct...
            My chunk is called "DittoBlog" and I call it in a cached document with {{DittoBlog}}. Is this correct?

            Boby
              ...my Photo Gallery on Flickr...
              • 18397
              • 3,250 Posts
              I just tried for a half hour to duplicate this error with no luck. Although I did notice something interesting. Calling the snippet cached vs uncached in the chunk made a difference as to what documents were retrieved. Jason, could this be an issue with documentMap being in the cache?

              @Boby, try everything uncached.
                • 3763
                • 155 Posts
                If I use multiple startID’s it works, but I have to enter them manually, [*id*] is not working sad

                This works:
                [[Ditto? &startID=`39,63` ... ]]


                This doesn’t:
                [[Ditto? &startID=`63` ... ]]


                But it does not work only when calling from a chunk, if I call Ditto directly from a document with multiple ID’s it works perfect.

                Boby
                  ...my Photo Gallery on Flickr...
                  • 3763
                  • 155 Posts
                  @ Mark

                  I think I’ve found a little bug. I’m not exactly sure when this happens, first I thought it’s when there is only one parent document with no subdocuments, so nothing to show, but sometimes it’s working sometimes not. The problem is that $resource is not always and array and when following code is compiled:
                  $resource = array_values($resource);

                  the error pop-ups because it can not handle only arrays.

                  So I’ve added one more validation criteria to snippet.ditto.php:

                  There is this code (line 344)
                  if (count($resource) < 1) { return $emptyText."\n"; }


                  I have replaced it with:
                  if (!is_array ($resource) || empty ($resource)) { return $emptyText."\n"; }


                  Thanks guys!
                  Boby
                    ...my Photo Gallery on Flickr...
                    • 18397
                    • 3,250 Posts
                    This has already been reported in the Ditto support thread and Ditto 1.0.3 is coming soon to a MODx install near you.

                    The reason [*id*] does not work correctly at the moment is because of too strict of a regex in a cleaning function. This will be removed in the next release. For now, just run in production mode as it bypasses the check.
                      • 18397
                      • 3,250 Posts