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

    I’m trying to fill a template variable with a result from a database call that depends on the id of the document. In order to do this I am using $modx->documentIdentifier in an @EVAL binding in the TV. To explain the problem simply, I’ll now say that the TV is filled with just the document ID of the page, and i’ll call the TV docID.

    If I place a call to view the contents of the TV in the template (by putting a [*docID*] call in the template), then when I view the document the correct ID is displayed. However, if I place a Ditto call in another page somewhere, to summarize many of such documents, with [+docID+] in the Ditto template, then when viewing the page with the Ditto call, for each element the ID displayed is the ID of the page where the Ditto call is, instead of the document IDs (so I get a list of identical IDs).

    How can I access the actual ID of a document in an @EVAL statement, even when the page is being accessed on another page via a ditto call?

    Tommy T.
      • 7923
      • 4,213 Posts
      This should be in Ditto forums as it seems to be an issue with Ditto. I’m not sure, but could there already be a placeholder in Ditto with that TV name? If so, the it will use the Ditto’s placeholder. Have you tried with another TV name that is more unique?


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 22303 MODX Staff
        • 10,725 Posts
        The problem is the @EVAL will be interpreted only in the context of the current request, in which $modx->documentIdentifier is the current page with the Ditto call. You’ll need to use Ditto’s placeholders that will already contain each documents id.
          • 30328
          • 35 Posts
          Quote from: OpenGeek at Jun 30, 2007, 02:07 PM

          The problem is the @EVAL will be interpreted only in the context of the current request, in which $modx->documentIdentifier is the current page with the Ditto call. You’ll need to use Ditto’s placeholders that will already contain each documents id.
          Ah ok... I will use the ditto [+id+] placeholder and send that as an argument to a snippet to access the database instead of using template variables.

          Thanks,

          Tommy T.