We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27302
    • 154 Posts
    I’m currently trying to get Ditto to display the children of the current documents ’grandparent’ dynamically.

    The structure is like this;

    ---Level 1
          ---Level 2
                ---Level 3
                      ---Level 4
                ---Level 3
                      ---Level 4
                ---Level 3
                      ---Level 4

    And so on. I would like the ditto call on Level 4 to display the immediate children of Level 2.

    Because of the way my site works I am having to use a different template for Level 3 and Level 4 documents. I need the Ditto call to list the immediate children of Level 2 documents dynamically (ie inputting the document id manually is not an option because the site will be so large).

    Currently for Level 3 documents my Ditto call is;
    [[Ditto?parents=`[*parent*]`&depth=`1` &tpl=`DittoSubCats` &sortBy=`id` &sortDir=`asc` &paginate=`1` &summarize=`6` &filter=`hidemenu,0`]] 


    This works well for that level, but for Level 4 something else is needed.

    I’ve tried using [+parent+] but that goes to the very first level. I have also tried embedding Ultimate Parent in the parents call, but it keeps giving me errors.

    I am sure Ultimate Parent is the solution to my problem, but I do not know how to embed the call properly into the Ditto call.
      • 7231
      • 4,205 Posts
      UltimateParent is the solution. The key is to alternate the cache of the embedded snippet calls [!Ditto? ...[[UltimateParent]]...!].
        [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]
        • 27302
        • 154 Posts
        This call is doing something
        [[Ditto?parents=`[[UltimateParent? &topLevel=`2`]]`&depth=`1` &tpl=`DittoSubCats` &sortBy=`id` &sortDir=`asc` &paginate=`1` &summarize=`6` &filter=`hidemenu,0`]]
        


        I tried
        [!Ditto?parents=`[[UltimateParent? &topLevel=`2`]]`&depth=`1` &tpl=`DittoSubCats` &sortBy=`id` &sortDir=`asc` &paginate=`1` &summarize=`6` &filter=`hidemenu,0`!]
        


        But it just displayed the actual Ditto call itself on the page.

        I’ve also tried
        [[Ditto?startID=`[[UltimateParent? &topLevel=`2`]]`&depth=`1` &tpl=`DittoSubCats` &sortBy=`id` &sortDir=`asc` &paginate=`1` &summarize=`6` &filter=`hidemenu,0`]]
        


        So far no luck.
          • 27302
          • 154 Posts
          Okay I tried
          [[Ditto?startID=`[!UltimateParent? &topLevel=`2`!]`&depth=`1` &tpl=`DittoSubCats` &sortBy=`id` &sortDir=`asc` &paginate=`1` &summarize=`6` &filter=`hidemenu,0`]]
          


          Along with a few variations of this along with using parent in the Ditto call instead of startID, I can only get the very top level of the tree structure to display no matter what I set the topLevel number to.
            • 7231
            • 4,205 Posts
            Looks like it should be working. Try adding some space between the first parameter, I read that this could cause some error, worth a try:

            [[Ditto? &parents=`[!UltimateParent? &topLevel=`2`!]` &depth=`1` ...]]
              [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]
              • 27302
              • 154 Posts
              Nope, still not working. It keeps showing me the absolute root level of the site. I think I’ve tried almost every combination possible, so not sure where to go now.
                • 27302
                • 154 Posts
                Okay, I tried UltimateParent on its own using topLevel and it is returning the correct document id that I require. The only trouble is that I just can’t get it to work with Ditto.

                At the moment the call is like this;
                [[Ditto?&startID=`[!UltimateParent?&topLevel=`3`!]` &depth=`1` &tpl=`DittoSubCats` &sortBy=`id` &sortDir=`asc` &paginate=`0` &summarize=`4` &filter=`hidemenu,0`]]
                


                Now it is telling me that there are No Documents Found.

                As a side not if I call Ditto with [! and Ultimate Parent with [[ nothing works at all.
                  • 4310
                  • 2,310 Posts
                  Is your latest call on a level 4 page? If it was on a level 3 page I think there would be no parent returned.
                  Do you have the page set as not cacheable, ditto as [[...]] and UltimateParent as [!...!] ?
                  Have you tried a simple call ? eg.
                  [[Ditto? &startID=`[!UltimateParent? &topLevel=`2`!]]
                    • 27302
                    • 154 Posts
                    Sorry, I made a mistake in my initial diagram. There are actually 5 levels. If I use Ultimate Parent on its own and use topLevel=`3` it is correctly showing the id of the parent document that I require.

                    I have turned off the cacheble option on the page that the call is made from.

                    This is the page in question
                    http://www.coolactiv.com/test.html

                    Excuse the mess as it is in its very early stages (and I don’t know if it works in IE etc so my apologies if the layout doesn’t work properly at the moment)!

                    This uses the call
                    [[Ditto? &startID=`[!UltimateParent? &topLevel=`3`!]` &depth=`1` &tpl=`DittoSubCats` &sortBy=`id` &sortDir=`asc` &paginate=`0` &summarize=`4` &filter=`hidemenu,0`]]
                    


                    As you can see it is showing the top level contents on the left hand side. What it should be showing is as shown on this page;

                    http://www.coolactiv.com/mountain-biking.html


                    I had considered Wayfinder, but I need it to display a thumbnail picture that I can assign to a document.
                      • 7231
                      • 4,205 Posts
                      I had considered Wayfinder, but I need it to display a thumbnail picture that I can assign to a document.
                      FYI - you can use a TV and display the image in wayfinder if you want. It is a little known fact that as of version 2, you can use template variables in wayfinder tpl chunks. Just call them as you would normally (without the wf. prefix, ex: [+VarNameHere+]). Also you can use the GetField snippet in the wayfinder chunk to get any field available as well.

                      However this should work in Ditto, no reason to give up just yet.
                        [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]