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.
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."
-
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.