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

    I’m wondering if Ditto calls can be "nested", as in Page 1 has a ditto call in the content that references a subpage that also has a Ditto call in the content.

    An example of usage would be if I wanted to group articles into categories, the categories represented as pages in the MODx tree, underneath which, pages represented the actual articles.

    I’ve tested it, and it appears that a Ditto call referencing another Ditto call results in an out of memory error. I’m wondering if there’s something I’m doing wrong, or can do to achieve what I’m trying to do.

    Thanks,

    Chris
      • 7231
      • 4,205 Posts
      You can nest snippets. Remember to alternate the snippet call cache settings [[ [! !] ]]
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 5210
        • 43 Posts
        Thanks!

        Have a strange result. It appears that both Ditto calls run, but the second call just repeats the content field of the first call. It’s like the second (nested) call doesn’t look to subdocuments for content, it just displays the content field it’s actually in.

        Here’s the first call (in the content field of "Page 1"):

        [[Ditto? &depth=`1` &display=`all` &orderBy=`menuindex asc` &tpl=`dittotccall`]]


        Here’s the second call (in the content field of "Page 2"):

        [!Ditto? &tplFirst=`tabbedcontentpage1` &tpl=`tabbedcontentpage` &display=`all` &orderBy=`menuindex asc`!]


        If you want to see the test page, visit: http://www.venhillusa.com/index.php?id=32

        Thanks for the help!

        Chris
          • 7231
          • 4,205 Posts
          In this case you may need to use the &id parameter to assign a unique id to each instance of Ditto.
          http://ditto.modxcms.com/files/snippet-ditto-php.html#id
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 5210
            • 43 Posts
            Adding "id=`1`" to the first call and "id=`2`" to the second call results in the same behavior. I can now see the "id=`2`" within the second content block.

            I modified the "parent" Ditto call template so I would be able to tell more accurately what is happening.

            It looks like the first Ditto call is repeating at the location of the second Ditto call. The second Ditto call is not running at all.

            To clarify, I have the first Ditto call in a document, then the second call in a subdocument of the first. Both calls are in their respective Content fields, and the second call falls after some standard text content.

            Any more ideas?

            Chris
              • 3749
              • 24,544 Posts
              Quote from: chrison600 at Mar 27, 2009, 08:09 PM

              Adding "id=`1`" to the first call and "id=`2`" to the second call results in the same behavior. I can now see the "id=`2`" within the second content block.

              Did you put an ampersand in front of the parameter name (&id=`1`) ?

                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 22427
                • 793 Posts
                Maybe you need the parameter &hiddenFields (its only one day ago I realized its existence...)
                  • 5210
                  • 43 Posts
                  Quote from: BobRay at Mar 27, 2009, 09:23 PM
                  Did you put an ampersand in front of the parameter name (&id=`1`) ?

                  Yes. The content fields look like this:

                  Page 1 (Parent):

                  [[Ditto? &depth=`1` &display=`all` &orderBy=`menuindex asc` &tpl=`dittotccall` &id=`1`]]

                  Page 2 (Child):

                  If you never know what you’ll need a hose or cable for, Venhill™ kits cover a wide range of makes and models without a huge expense. Whether you’re fixing, upgrading, or finishing a custom job, Venhill dealer kits include enough pieces to satisfy the most common customer requests, packed in neat, organized, inexpensive kits.

                  Powerhose Plus Kit: Braided stainless steel hoses that are quick, easy, and DOT-approved. Pick the hose; pick the fittings; put it together and you’re done!

                  Powerhose Kit: A versatile, bulk braided stainless steel hose system. Build your own complete hoses from scratch!

                  [!Ditto? &tplFirst=`tabbedcontentpage1` &tpl=`tabbedcontentpage` &display=`all` &orderBy=`menuindex asc` &id=`2`!]

                  The content above is what I see at the location of "call 2" in the webpage.

                  Any thoughts?

                  Chris
                    • 19667
                    • 26 Posts
                    Hi Chris,

                    Not quite sure.  But have you  tried this?

                    [!Ditto? &tplFirst=`tabbedcontentpage1` &tpl=`tabbedcontentpage` &display=`all` &orderBy=`menuindex asc` &id=`[+id+]`!]
                      • 5210
                      • 43 Posts
                      Hi 0x7B,

                      The only thing that changes is the content shown on the page, as in:

                      [!Ditto? &tplFirst=`tabbedcontentpage1` &tpl=`tabbedcontentpage` &display=`all` &orderBy=`menuindex asc` &id=`2`!]

                      becomes

                      [!Ditto? &tplFirst=`tabbedcontentpage1` &tpl=`tabbedcontentpage` &display=`all` &orderBy=`menuindex asc` &id=`33`!]

                      Anyone?

                      Chris