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

    I’m looking for a little help with ditto if possible

    I am creating a business directory and each catagory has 2 sub catagories, then there are a number of documents under these sub cats like this:

    Pubs
    --free adverts
    -----1st free advert
    -----2nd free advert
    -----3rd free advert
    -----4th free advert

    --Paid adverts
    -----1st paid advert
    -----2nd paid advert
    -----3rd paid advert
    -----4th paid advert

    These are called using 2 seperate calls.

    Now I have these working as required apart from 1 part.

    I have created a tv called startid_ free and startid_paid and I enter the start id when I create the document. I want to do it like this so that I can run the 30 ish catagories fron 3 templates and not have to create new templates for each cat.

    So the idea is that ditto gets the start ID fron the template variable however it just isn’t working.

    Could anyone offer any help please.

    I’ve tried the following calls

      [[Ditto? &tpl=`free_advert` &startID=`startid_ free`]]

      [[Ditto? &tpl=`free_advert` &startID=`[[startid_ free]]`]]

      [[Ditto? &tpl=`free_advert` &startID=`[!startid_ free!]`]]

      [[Ditto? &tpl=`free_advert` &startID=`[*startid_ free*]`]]

      [[Ditto? &tpl=`free_advert` &parent=`startid_ free`]]

      [[Ditto? &tpl=`free_advert` &parent=`[[startid_ free]]`]]

      [[Ditto? &tpl=`free_advert` &parent=`[!startid_ free!]`]]

      [[Ditto? &tpl=`free_advert` &parent=`[*startid_ free*]`]]

    I’ve also used

      [[Ditto? &tpl=`free_advert` &parent=`[*parent*]`]]

    But that pulls from the ultimate document parent and not the sub parent
      • 7231
      • 4,205 Posts
      [[Ditto? &tpl=`free_advert` &parents=`[*startid_free*]`]]
      This should work. The startId parameter is deprecated in Ditto, ue parents instead. Also there was a space in the TV name "startid_ free" rahter than "startid_free".
        [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]
        • 22840
        • 1,572 Posts
        Thanks for the reply,

        Now i’ve removed the space I do get a output but its only "No documents found.".

        So heres what im doing but with id’s

        Pubs(2)
        --free adverts(3)
        -----1st free advert(4)

        Now when I created 1st free advert(4) i entered 3 in the `startid_free` template variable which is a text box, so therefore I was hoping that it would insert 3 into the call making it
        [[Ditto? &tpl=`free_advert` &parents=`3`]] as aposed to [[Ditto? &tpl=`free_advert` &parents=`[*startid_free*]`]] and echo out all the pages under "free adverts(3)"

        Am I correct in thinking this ?? or am I totaly off track rolleyes
          • 7231
          • 4,205 Posts
          That’s the way it should work. Test the output of the TV by placing it outside the ditto call (or set &debug=`1` in the ditto call to get the console, that can really help).
            [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]
            • 22840
            • 1,572 Posts
            Thanks for that,

            If I add [*startid_free*] outside of the ditto call in the template it returns nothing at all, then using the debug the startid is 0 so I’m presuming that the startid_free isnt pulling the details needed.as it should be 3
              • 7231
              • 4,205 Posts
              That is what I was thinking. How are you setting up the TV? What is it that you want it to do? Maybe a snippet could be used if it is follows a pattern (grandparent, second level from the top, ..).
                [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]
                • 22840
                • 1,572 Posts
                Hi dev_cw,

                Every parent will have several sub cats, then each of the subcats has 2 subcats where the docs are stored (free adverts and paid adverts), so basicley all I need to do is call all the docs under the free and paid adverts into the ditto call.

                parent cat
                --pubs
                ----free advert
                ------doc 1
                ------doc2
                ----paid advert
                ------doc 1
                ------doc2

                The way it is set up now is that the ditto call is in the template, I have set up the TV but as above it doesn’t call the TV outside of the ditto call or in it.

                If there is a easier way of doing this that would be great as it will reduce the amount of templates I have to use, and as theres going to be about 20 sites using the same system it will reduce my work loadby a massive amount.
                  • 7231
                  • 4,205 Posts
                  The TV should work so there may be something not correct in your setup.

                  Now there is an easier way, You can use the UltimateParent snippet to return the ID of the parent document X levels deep from the root. In your example I am guessing that Free Advert and Paid Advert are at the same level in the doc structure. I am guessing that they are 3 levels deep (root is 0).

                  [[Ditto? &tpl=`free_advert` &parents=`[!UltimateParent? &topLevel=`3`!]`]] 


                  Another cool sippet that is not widely used is SectionRoots, this is handy if the roots are not always in the same level. note: I have used this in the past but don’ know if it still works with 0962. In any case you would use it like the eample above replacing the UltimateParent call.

                  [[Ditto? &tpl=`free_advert` &parents=`[!SectionRoots? &Sec_roots=`10,17,32,55,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]
                    • 22840
                    • 1,572 Posts
                    Thanks dev_cw,

                    Now there is an easier way, You can use the UltimateParent snippet to return the ID of the parent document X levels deep from the root. In your example I am guessing that Free Advert and Paid Advert are at the same level in the doc structure. I am guessing that they are 3 levels deep (root is 0).

                    That is correct, the structure stays the same right through the menu and they are the 3rd level.

                    [[Ditto? &tpl=`free_advert` &parents=`[!UltimateParent? &topLevel=`3`!]`]]
                    I tried using that however is doesn’t return the correct documents, for some reason that returns 11 docs that are all top level, now the strange thing is if I change that to 2 or 1 it still returns the same.

                    This is soo annoying as these should be working and I’m obviousley missing something here but just can’t work it out.

                      • 22840
                      • 1,572 Posts
                      Right, if I use  [!Ditto? &tpl=`free_advert` &parents=`[[UltimateParent?&topLevel=`3`]]` &debug=`1`!] it pulls out the free advert and paid advert document so nearly there, i’ve been playing with the numbers but can’t actually get it to pull the docs under free and paid.