We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18830
    • 161 Posts
    I want to implement this snippet

    http://modxcms.com/forums/index.php/topic,13561.msg88877.html#msg88877

    into a Ditto template. But I couldn’t make out how to do.

    This thread seems to provide a solution

    http://modxcms.com/forums/index.php/topic,13401.0.html

    but I must admit that I didn’t understand it. :’(

    This is my Ditto call:

    [!Ditto? &startID=`77` &summarize=`5`  &tpl=`name_of_template` &displayArchive=`0` &sortBy=`menuindex` &sortDir=`DESC` !]


    and that the (wrong) template:

    <h3>[+longtitle+]</h3>
    [+name_of_snippet+]
    [+content+]


    What am I doing wrong?

    Im using Dittos latest version and MODx 0.95
      • 18397
      • 3,250 Posts
      [+name_of_snippet+] should be [[name_of_snippet]]
        • 18830
        • 161 Posts
        Well, Mark, you are right. It is not Ditto’s fault but mine.

        The snippet I’m using can’t work this way with Ditto because this

        $tvout=$modx->getTemplateVarOutput('image',$modx->documentIdentifier);


        will look for an TV "image" at the doc with the Ditto call.

        But of course it needs the ID from the document with the TV image.

        Home... this is calling the sippet
        .
        .
        .
        imagedoc1... this one contains the TV image
        imagedoc2... and this one too

        Can somebody tell me how I will get the IDs of imagedoc1 and imagedoc2, please.


          • 23491 ☆ A M B ☆
          • 1,056 Posts
          Would something like this work?
          [[name_of_snippet?id=`[+id+]`]]
          


          I believe Ditto will pass current doc ID to the placeholder, which eventually gets fed to your custom snippet.

          However, you’d need to modify custom snippet to use incoming id parameter, rather than defaulting to $modx->documentIdentifier. I would update the logic, and use $modx->documentIdentifier as the fall-back... can anyone confirm? (My use of Ditto is limited)
            Mike Reid - www.pixelchutes.com
            MODx Ambassador / Contributor
            [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
            ________________________________
            Where every pixel matters.
            • 18397
            • 3,250 Posts
            Couldn’t have said it better myself Mike.
              • 18830
              • 161 Posts
              Thank you, Mike. But may I ask another question?

              What can I use instead of

              [url]$modx->documentIdentifier|/url] ?

              How can I implement the docs ID into the snippet?
                • 11975
                • 2,542 Posts
                Hi,

                You could check first if an id has been passed by ditto
                and if not use $modx->documentIdentifier.

                $docID = (isset($docID)) ? $docID : $modx->documentIdentifier;
                $tvout=$modx->getTemplateVarOutput('image',$docID);
                


                and your call in ditto tpl

                [[snippet? &docID=`[+id+]`]]
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                  • 18830
                  • 161 Posts
                  Thank you, Heliotrop. It works perfectly (and I’m really happy).