We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    So I was trying to nest ditto statements and am having no luck of course.

    Is it possible to have ditto call a document that has a ditto call that calls a document that has a ditto call that calls a document, etc?

    So basically we have three ditto calls with the right templates the output should be:

    <Call 1>
    	<Call 2>
    		<Call 3>
    		Content
    		</Call 3>
    	</Call 2>
    </Call 3>


    Right now if I make a ditto call to another document with a ditto call and use a template with the [+summary+] placeholder, all I get for the output is the unparsed second ditto call. So I am guessing that the first ditto call grabs the contents of the second document as a string before it is ever parsed? However, if I place my first ditto call in the template and call a document that has a ditto call, it seems to parse that just fine. So anyone who understands how ditto operates or how MODx parses that calls, care to elaborate? Is there any workaround for getting nested ditto calls to work?
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
      • 18397
      • 3,250 Posts
      Ditto does not actually parse the content it retrieves, MODx does. Dependening on your MODx version, MODx goes parses the page n times before stopping. Also, nested calls are only supported in the current parser when formatted as alternating caching and noncaching calls. IE [! inside [[ and [! inside of that.

      What would having nested Ditto statements accomplish that you could not do with one call?
        • 14050
        • 788 Posts
        I would going to have the documents wrap themselves in the appropriate html containers based on their location in the document tree.

        For example, look at the markup of this page:

        http://www.fredsbarn.com/sandbox/multiflex3/layout4_full.html

        The layout basically uses a container called "main-content." Inside that container are "content-units." Each "content-unit" can contain a "1-column-unit," "2-column-unit-left," "2-column-unit-right," "3-column-unit-left," "3-column-unit-middle," and "3-column-unit-right." Further any of those "column-units" can contain "text-units."

        So to be able to dynamically create the layout, I thought I would have to use nested ditto calls using my template hack I did to ditto. For example I would set up the documents for a lengthy page like this:

        Page
        Main Content
        Content Unit A
        1-column-unit
        text-unit
        text-unit
        Content Unit B
        2-column-unit-left
        text-unit
        text-unit
        2-column-unit-right
        text-unit
        text-unit

        Uses my hack, each document would determine what chunk to call as its template. So in the "Page" you would do your ditto call starting at "Main Content," which would create Content Unit A and B on the "Page." But the contents of Unit A and B would be ditto calls to what is within them and so on, so that it builds the appropriate html structure dynamically to look like this:

         <!-- Content unit - One column -->
                <div class="content-unit">
                  <div class="column1-unit">
                    <div class="text-unit">
        			*CONTENT*
                    </div>  
                    <div class="text-unit">
        			*CONTENT*
                    </div>  
                  </div>          
                </div>
                  
                <!-- Content unit - Two columns -->
                <div class="content-unit">
                  <div class="column2-unit-left">
                    <div class="text-unit">
                      *CONTENT*
        			</div>              
                    <div class="text-unit">
        			  *CONTENT*
        		    </div>
                  </div>
                  <div class="column2-unit-right">
                    <div class="text-unit">
        			   *CONTENT*
                    </div>              
                    <div class="text-unit">
                      *CONTENT*
        			</div>              
                  </div>
                </div>


        Now using the ditto calls that return data that was a ditto call would allow me to build this data structure in a recursive way. On the other hand, the user has to set his data up in this type of structure. I am trying to also alter the template to maintain its flexibility, while simplifying all the containers that are used as. For instance, text-units could probably be emulated by just using header tags, and thus eliminates a container. But I am no CSS wiz by any means, and I am sure there is a simpler way. So if so, let me know. Then end goal is to have a template that is has flexible as he intended it, and not just porting it in such a way that the user is forced into a very fixed template that I decided to place a couple TVs to. The more I think about it, it is kind of like using the method Wayfinder does to build its menu’s by using the [+wf.wrapper+]. Except I need the documents to wrap themselves in their appropriate wrapper. Is there an easier, more elegant, and more efficient way to do this? I am probably trying to put a square peg in a round hole, eh?

        Jesse
          Jesse R.
          Consider trying something new and extraordinary.
          Illinois Wine

          Have you considered donating to MODx lately?
          Donate now. Every contribution helps.
          • 17064
          • 35 Posts
          Quote from: Mark at Nov 17, 2006, 02:54 PM

          Ditto does not actually parse the content it retrieves, MODx does. Dependening on your MODx version, MODx goes parses the page n times before stopping. Also, nested calls are only supported in the current parser when formatted as alternating caching and noncaching calls. IE [! inside [[ and [! inside of that.

          What would having nested Ditto statements accomplish that you could not do with one call?

          I have the same problem. I need place information from 2 different pages only on one page, cause it looks perfectly for me. And I can do it if I have for example one chunk width 2 ditto calls. But I can’t do it, because ditto doesn’t support it and I have to do 2 pages with 1 ditto call in each of them.

          So, I really need nested ditto calls. Is it work if i use this combination [! inside [[ and [!?

          Mark, do you have any ideas? Thx. smiley
            • 18397
            • 3,250 Posts
            If you need to get data from multiple parents just do &startID=`1,2,3,4,5`
              • 14050
              • 788 Posts
              Mark,

              If I need the the child inside the child of the parent to output the data first, then I need to nest the ditto calls. If I call the parents using a ditto call to the parents using "startID=blah1, blah2, blah3." I twill output blah1, then blah2, then blah3. But what If I need it to output blah 3 as a html chunk inside blah 2, which is a chunk inside blah 1? That takes nesting. I don’t think there is any other way to emulate automatic generation of div containers, without nesting ditto calls.

              Jesse
                Jesse R.
                Consider trying something new and extraordinary.
                Illinois Wine

                Have you considered donating to MODx lately?
                Donate now. Every contribution helps.
                • 17064
                • 35 Posts
                Quote from: jesster444 at Nov 20, 2006, 10:28 PM

                Mark,

                If I need the the child inside the child of the parent to output the data first, then I need to nest the ditto calls. If I call the parents using a ditto call to the parents using "startID=blah1, blah2, blah3." I twill output blah1, then blah2, then blah3. But what If I need it to output blah 3 as a html chunk inside blah 2, which is a chunk inside blah 1? That takes nesting. I don’t think there is any other way to emulate automatic generation of div containers, without nesting ditto calls.

                Jesse

                Yes, I need this too smiley))
                  • 4195
                  • 398 Posts
                  The PHx plugin will get you wat you want and supports "unlimited" nesting. The only thing you have to do is to install the latest plugin version. When activated, nesting of all MODx tags (uncached or cached doesn’t matter) is automatically supported.
                    Armand Pondman
                    MODx Coding Team
                    :: Jot :: PHx