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

    I am trying to call a ditto request which will receive data from various parents. No prob i thought:
    [!Ditto? &parents=`2,5,56,57`!]


    That works as expected. Nice!

    Now I want only ONE document from every parent. Which means i only need 4 documents, one for each parent. How can I manage that?
    At the moment i simply have 4 ditto-requests – seems quite ugly to me.

    Thanks in advance.
      • 18397
      • 3,250 Posts
      The cleanest way would be to write an extension that filters out documents once it has one from any given parent. However, given you only want four documents, your method should work fine unless your are dealing with >1000 documents in those folders.
        • 9849
        • 74 Posts
        Hmm, I know how to build an extender (at least I think so, as there is an example extender with comments) but I do not know how to code THE extender for my special case. rolleyes

        Do you mean I should code a filter function? How can i incorporate the counting? I think i have to count how many documents he (ditto) received from one container (max 1 in my case) and then break over to the next container. I have absolutely no idea how to achieve that.
          • 9849
          • 74 Posts
          Please, I need some help with this. I cannot believe no one suffered of this before!

          To make it easier to understand I give you a scribble of what I have:
          Site
          |--Navigation A
          |--Navigation B
               |–-Parent A
                    |–-News A 1
                    |–-News A 2
                    |–-News A 3
               |–-Parent B
                    |–-News B 1
                    |–-News B 2
               |–-Parent C
                    |–-News C 1
                    |–-News C 2
                    |–-News C 3
                    |–-News C 4
               |–-Parent …
          |--Navigation C
          |--Navigation D
          |--Navigation …
          


          And what I need (for example on Navigation D):
          – Just one News (latest, sorted by editedon) from Parent A
          – Just one News (latest, sorted by editedon) from Parent B
          – Just one News (latest, sorted by editedon) from Parent C
          …
          


          Anyone here to help me writing an extension?
            • 11975
            • 2,542 Posts
            Hi,

            if you don’t want to write a line of code here is a way to go:

            [[ditto? &parents=`A,B,C` &tpl=`dittoSubCall` &display=`all`]]

            in {{dittoSubCall}}

            [[ditto? &parents=`[+id+]` &tpl=`myItemTPL` &display=`1`]]

            :-)
              Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
              • 9849
              • 74 Posts
              OMG! Thank you so much.
              I just had to change &parents into &documents inside of the chunk and it worked like a charm.