This is one of those that i didn’t think would be a problem, but after trying different things i still can’t find a solution.
Here’s the situation.
I need to run some code to populate a drop down list in a template variable. So i wrote a snippet to execute the necessary logic. But the logic needs to know the id of the document that the values are being populated for. I tried the following from within @EVAL of a tv and from a snippet that was being called from tv @EVAl with no success:
$myID = $modx->documentObject[’id’];
$myID = $modx->documentIdentifier;
Although all of these methods work fine when the snippet is called from the template.
So i suspect that different document parsing takes place when a document is loaded in the manager.
This seems to be pretty fundamental so it leads me to believe that i’m missing something obvious.
Any help would be greatly appreciated.
-
☆ A M B ☆
- 24,524 Posts
When you are editing a resource, the resource ID is in the $_GET[’id’] and it’s made available as the $id variable (it’s set in line 37 of the manager/actions/mutate_content.dynamic.php file).
When editing a resource, it’s not being parsed. You are just being provided a form to set all the metadata and content values for the resource. The $modx object is loaded just to provide some useful global values and functions, but since the resource isn’t actually going through the parser the documentObject and similar objects and arrays aren’t available.
@Susan
that’s what i suspected. i didn’t even look at the url. thank you for the suggestion
@lucas
that’s a different take and totally makes sense. thanks for the pointer