This question has been answered by opengeek. See the first response.
<?php
$parentID = $modx->resource->get('parent');
$menuIndex = $modx->resource->get('menuindex');
$theparent='';
if ($parentID==19) {
$theparent=21;
} else {
$theparent=19;
}
$resourceObject = $modx->getObject('modResource', array('parent'=>$theparent, 'menuindex'=>$menuIndex));
$theID = $resourceObject->get('id');
return $theID;<?php
$parentID = $modx->resource->get('parent');
$menuIndex = $modx->resource->get('menuindex');
$theparent='19';
if ($parentID!==19) { $theparent=21; };
$resourceObject = $modx->getObject('modResource', array('parent'=>$theparent, 'menuindex'=>$menuIndex));
$theID = $resourceObject->get('id');
return $theID;This might be asking for trouble, imo. If even one resource is dragged to a new location in the tree (even by accident), all the menuindex values can be rewritten.
You could use a TV instead of menuindex, but it would be faster if you could use the introtext or description field.

return $modx->getObject('modResource', array('parent'=>$modx->resource->get('parent') == 19? 21 : 19,'introtext'=>$modx->resource->get('introtext')))->get('id');
$theparent = $modx->resource->get('parent') == 19? 21 : 19;
return $modx->getObject('modResource', array('parent'=>$theparent,
'introtext'=>$modx->resource->get('introtext')))->get('id');
$obj = $modx->getObject('modResource', array('parent'=>$modx->resource->get('parent') == 19? 21 : 19,'introtext'=>$modx->resource->get('introtext')));
return $obj->get('id');$theparent = $modx->resource->get('parent') == 19? 21 : 19;
$obj = $modx->getObject('modResource', array('parent'=>$theparent,
'introtext'=>$modx->resource->get('introtext')));
return $obj->get('id');
$criteria = array(
'parent' => $modx->resource->get('parent') === 19? 21 : 19,
'introtext' => $modx->resource->get('introtext')
);
return $modx->getValue($modx->newQuery('modResource', $criteria)->prepare());$criteria = $modx->newQuery('modResource', array(
'parent' => $modx->resource->get('parent') === 19? 21 : 19,
'introtext' => $modx->resource->get('introtext')
));
$criteria->select('id');
return $modx->getValue($criteria->prepare());Very cool! And way less memory than pulling a monster modResource object.The select() would make that unnecessary...
If you were getting another column, would you have to specify the column number in getValue(), or would the select() make that unnecessary?