We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33982 ☆ A M B ☆
    • 476 Posts
    So I’m trying to figure out how to simply get the Child Count of documents using Ditto. I’ve looked around the forums and I see that there are some examples using Wayfinder which really are not working so well with my situation, but I’m not seeing anything with Ditto.

    Essentially I have a ditto call like so:
    [!Ditto? &parents=`[*id*]` &tpl=`class_tpl` &sortBy=`menuindex` &sortDir=`ASC`!]


    Then the coding for the tpl is:
    <h2>[+pagetitle+]</h2>
    <p>XXX Classes</p>
    [+summary+]
    


    I need the "XXX" to be replaced with the number of children for that particular container. The hierarchy is like so:

    - Courses
    -- Course Title 1
    --- Class 1
    --- Class 2
    --- Class 3
    -- Course Title 2
    --- Class 1
    --- Class 2
    --- Class 3

    Anyone had any experience with this? Thanks!
      Precision Web Development ... SmashStack.com
      • 7231
      • 4,205 Posts
      There is a snipet out there that will do this. Here, I think this snipet will do: http://modxcms.com/extras/package/67
        [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&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 22840
        • 1,572 Posts
        Looks like what Im looking for however I need to call it a different way, I am using ditto to pull in all children under a parent using the following call:

        [!Ditto? &extenders=`star_rating` &tpl=`site-list` &parents=`10` &orderBy=`pagetitle ASC` &paginate=`1` &paginateAlwaysShowLinks=`0` &summarize=`10`!]


        But I need this to call the children under the children and display it like Child(5)....

        So I have :

        -Parent
        --children
        ---children

        Is this possible using this snippet ??
          • 22840
          • 1,572 Posts
          Ok forget the last lol,

          How o I get it to display just the id’s of the parent ??
            • 22840
            • 1,572 Posts
            Ok sorted, should have played first wink

            I was calling this in a chunk so here is what I used:

             ( [[ChildrenCount? &parentId=`[+id+]`]] )


            So Flinx you would use:

            <h2>[+pagetitle+]</h2>
            <p>[[ChildrenCount? &parentId=`[+id+]`]] Classes</p>
            [+summary+]


            Hope that helps and sorry for hijacking your post grin
              • 33982 ☆ A M B ☆
              • 476 Posts
              <h2>[+pagetitle+]</h2>
              <p>[[ChildrenCount? &parentId=`[+id+]`]] Classes</p>
              [+summary+]

              Hey paulp,

              Thanks so much for providing the answer...I figured it was something simple like an existing snippet...thanks!

              http://modxcms.com/extras/package/67
                Precision Web Development ... SmashStack.com
                • 22840
                • 1,572 Posts
                No problem,

                But it was dev_cw that gave the answer ( he’s a legend round here you know, shhhhhhh don’t tell him, hell only get big headed ;o) )
                  • 7231
                  • 4,205 Posts
                  Just happy to help out grin grin grin
                    [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&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 22840
                    • 1,572 Posts
                    Quote from: dev_cw at Sep 22, 2009, 05:05 PM

                    Just happy to help out grin grin grin

                    And your help is always gratefully received, even if we don’t say it every time grin
                      • 20413
                      • 2,877 Posts
                      There is another option not mentioned:

                      [[Ditto? &id=`someID` &parents=`2` &save=`3` &paginate=`1`]]
                      Classes ([+someID_total+])


                      Probably causing more MySQL requests than necessary but I use it.
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower