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

    I was searching the MODx-Forums for more than an hour but couldn´t made it out.

    My problem:

    I need a snippet in a parent document that uses the ID for any child doucument listed in this parent document. Just for testing I put up this:

    <?php
    $childid= $modx->documentIdentifier;
    return $childid;
    ?>


    because I believed that documentIdentifier will give the same result as [+id+] used in a chunk.

    But while [+id+] returns the children’s ID, the above code returns the parent’s ID. sad

    Maybe I should use getActiveChildren but this one returns an array of all children. And OpenGeek’s GetChildID returns the parent’s ID plus 1.

    Does anyone knows a solution and could help me?
      • 15987
      • 786 Posts
      And OpenGeek’s GetChildID returns the parent’s ID plus 1.

      his code should work for what you want, all you need to do is set the depth to 1 and it will get the first child of the current document, or of the document number passed into the snippet.
        • 15297
        • 10 Posts
        :’( No, kylej. It just returns the ID of the first child (and not the aforementioned "partent’s ID plus 1" - in my case the parent’s ID ist 7, and I didn’t see that the first child’s ID is 8 ).

        It doesn’t matter If I set $depth zo 1 to 0 oder to 100 - in never get the right ID (besides for the very first child).
          • 15987
          • 786 Posts
          I’m not sure I understand what you are trying to accomplish?

          in a snippet $modx->documentIdentifier will return the current documents id

          the [+id+] placeholder used in a chunk will contain the currently processed document id

          It doesn’t matter If I set $depth zo 1 to 0 oder to 100 - in never get the right ID (besides for the very first child).

          so what child document are you trying to get if not the first one?
            • 15297
            • 10 Posts
            Please take a look at this site: elbwiese. Scroll down, and click at "barrierefreiheit" or whatever you want. After der "mehr"-link you will see three numbers: The first is the output of [+id+], the second from $modx->documentIdentifier and the third from GetDocuemntsId. The parent’s ID is 7, the smallest child ID is 8.

            I want to use a simple check box snippet. When activated there should be no [mehr]-Link which is not necessery when there is a link in the short description (like on CSS, CMS and other abbrevations).

              • 15987
              • 786 Posts
              what do you mean by check box snippet? if you want to post the code maybe I can help you figure the problem. I’m not sure how you are trying to determine which short descriptions contain a link or not.
                • 17883
                • 1,039 Posts
                Well, this is clear....

                The first is the output of [+id+], the second from $modx->documentIdentifier and the third from GetDocuemntsId. The parent’s ID is 7, the smallest child ID is 8.

                You use [+id+] in a ditto call/ in a ditto template. So every [+id+] is the id of the document summarized.

                $modx->documentIdentifier always delivers 7 becaus the ditto call is placed in the doc with id 7 (the current doc)

                And the third is the same "problem", you always get 8 because it is the first child of 7 (the current document). So you have to put your checkbox TV to your child documents and forward its content (I think this will be the more link) to the ditto template. So if there is no "more link" TV, ditto will not render it.

                Gruß aus Karlsruhe wink
                Marc
                  • 15297
                  • 10 Posts
                  Yes, MadeMyDay, this is a solution and easy to realize. But not this evening, 8 hours before the screen are enough wink

                  Thank you. And at least we all know how it does not work. grin