Just had to get into work.
I have attached a diff of the Wayfinder from 9.6.3, with my changes, and also posted them below.
Here is the modified function with the change from Ditto. My changes in the previous post allow TV replacement in the wrapper as well.
function appendTV($tvname,$docIDs){
global $modx;
$baspath= $modx->config["base_path"] . "manager/includes";
include_once $baspath . "/tmplvars.format.inc.php";
include_once $baspath . "/tmplvars.commands.inc.php";
$tb1 = $modx->getFullTableName("site_tmplvar_contentvalues");
$tb2 = $modx->getFullTableName("site_tmplvars");
$query = "SELECT stv.name,stc.tmplvarid,stc.contentid,stv.type,stv.display,stv.display_params,stc.value";
$query .= " FROM ".$tb1." stc LEFT JOIN ".$tb2." stv ON stv.id=stc.tmplvarid ";
$query .= " WHERE stv.name='".$tvname."' AND stc.contentid IN (".implode($docIDs,",").") ORDER BY stc.contentid ASC;";
$rs = $modx->db->query($query);
$tot = $modx->db->getRecordCount($rs);
$resourceArray = array();
for($i=0;$i<$tot;$i++) {
$row = @$modx->fetchRow($rs);
$resourceArray["#{$row['contentid']}"][$row['name']] = getTVDisplayFormat($row['name'], $row['value'], $row['display'], $row['display_params'], $row['type'],$row['contentid']);
}
//new code direct from ditto
if ($tot != count($docIDs)) {
$query = "SELECT name,type,display,display_params,default_text";
$query .= " FROM $tb2";
$query .= " WHERE name='".$tvname."' LIMIT 1";
$rs = $modx->db->query($query);
$row = @$modx->fetchRow($rs);
foreach ($docIDs as $id) {
$defaultOutput = getTVDisplayFormat($row['name'], $row['default_text'], $row['display'], $row['display_params'], $row['type'],$id);
if (!isset($resourceArray["#".$id])) {
$resourceArray["#{$id}"][$tvname] = $defaultOutput;
//$resourceArray["#$id"]["tv".$tvname] = $resourceArray["#$id"][$tvname];
}
}
}
return $resourceArray;
}