How could I use this on going down the tree?
This snippet works great on individual pages, I didn’t create it myself that goes to the wonderful modx developers reply in a forum.
Current Page
I can use this [[CustomSnippet]] which is great or any other place directly related to the specific page
<?php
$output = '';
$myArray = $modx->getTemplateVarOutput(array('tv1','tv2'));
if(empty($myArray['tv1'])){
} else {
$output .= '<h3>'.$myArray['tv1'].'</h3>';
}
if(empty($myArray['tv2'])){
} else {
$output .= '<h3>'.$myArray['tv2'].'</h3>';
}
return $output;
?>
The challenge.
Trying to use it one above or two above.
Parent Page using Ditto doesn’t appropriately associate the tv variable with the correct document ID.
Resource container holding documents using Ditto
Ditto $tpl=`ChunkName` &parents=`32`
ChunkName = {{ [+pagetitle+] [[SnippetBelow]] }}
<?php
$output = '';
$parent = $modx->documentObject[id];
$tvidnames=(array('tv1','tv2'));
$myArray = $modx->getDocumentChildrenTVarOutput($parent, $tvidnames);
$new=array_merge(array(),$myArray); // Used this because I couldnt find my around it show the Document ID = [id] of specific child id.
if(empty($new[0][tv1])){
} else {
$output .= '<h3>'.$myArray['tv1'].'</h3>';
}
if(empty($new[0][tv2])){
} else {
$output .= '<h3>'.$myArray['tv2'].'</h3>';
}
return $output;
?>
If I have totally lost you, then you are already to kind to indulge me! SO thank you in advance