<?php $parent = $modx->getParent($iddoc,1,$field); return $parent[$field]; ?>
[!ZoomImage? &iddoc=`[*id*]` &field=`introtext`!]
[!ZoomImage? &iddoc=`[*id*]` &field=`SpecialPic`!] or [!ZoomImage? &iddoc=`[*id*]` &field=`[*SpecialPic*]`!] or Anything else...
$tvPr = $modx->getTemplateVarOutput(array("price"),$docid='2',$published=1);
echo $tvPr['price'];
$parent = $modx->documentObject['parent'];
$tv = $modx->getTemplateVarOutput(array("$field"),$parent);
return $tv[$field];
Check out getField http://modxcms.com/extras/package/?package=173
That function only works for the resource variables; it uses the site_content table. That’s why it complains about not finding it in the database.
You’ll need to use the getTemplateVarOutput() API function; here’s the example from the wiki
$tvPr = $modx->getTemplateVarOutput(array("price"),$docid='2',$published=1); echo $tvPr['price'];
Just replace the $docid=’2’ with the $parent variable. You’d probably be just as well off using the $modx->documentObject[’parent’] yourself since that’s what the getParent function uses, and all you want from it is the parent ID.
$parent = $modx->documentObject['parent']; $tv = $modx->getTemplateVarOutput(array("$field"),$parent); return $tv[$field];
This discussion is closed to further replies. Keep calm and carry on.