Hello
I would like to know, if possible, how to get the value of a template variable for a specific document.
For example, I have created a TV called menuTitle_en and I want to get its value from another document.
Is there a syntax like [*menuTitle_en*:docId] ? (where docId is the id of the document that I want to get the TV value)
Thank you in advance
-
MODX Staff
- 10,725 Posts
You can use the GetField snippet for this purpose I believe; or roll your own using the API functions.
Good way of pulling a list of TV values for a doc:
$tvPr = $modx->getTemplateVarOutput(array(’name_of_tv’),$docid=100,$published=1);
// If doc is not published...
if (empty($tvPr))
{
$tvPr = $modx->getTemplateVarOutput(array(’name_of_tv’),$docid=100,$published=0);
}
Access it:
$tvPr["name_of_tv"];
This help?