This question has been answered by djad33. See the first response.
Would weblinks work?
offsetChildren=`parent_id|resource_id_of_child:desired_menuindex,resource_id_of_2nd_child:desired_menuindex||repeat pattern for each parent as needed
offsetChildren=`4|95:998,23:999`
offsetChildren=`4|95:998,23:999||6|24:800,14:801||9|95,23`
$this->getData()
$this->offsetParents //contains the ids of the parents set in the param
/*Array
(
[0] => 4
)
*/
$this->offsetChildren //contains the adoptive children [key] with parent and menuindex
/*
Array
(
[95] => Array
(
[parent] => 4
[menuindex] => 998
)
[28] => Array
(
[parent] => 4
[menuindex] => 999
)
)
*/
if($this->offsetChildren)
//loop through the results
for($i=0;$i<$numResults;$i++) {
$new_doc = null; //NEW - prevent duplicate resource from gumming up the works
$tempDocInfo = $modx->db->getRow($result);
$resultIds[] = $tempDocInfo['id'];
//NEW - test for offsetChildren and duplicate $tempDocInfo and insert new values - ****
if($this->offsetChildren){
if(array_key_exists($tempDocInfo['id'],$this->offsetChildren)){
$new_params = $this->offsetChildren[$tempDocInfo['id']];
$new_doc = $tempDocInfo;
$new_doc['parent'] = $new_params['parent']; // set adoptive parent id
$new_doc['menuindex'] = $new_params['menuindex']; // set our menuindex value
$resultIds[] = $new_doc['id'];
}
}
//Create the link
if($new_doc){
$this->hasChildren[] = $new_doc['parent'];
}
//used with each statement -- I don't know if they are all necessary, but I didn't want to break anything important
if($new_doc){
$resourceArray[$new_doc['level']][$new_doc['parent']][] = $new_doc;
}
function run() {
global $modx;
[...]
//Get all of the documents
$this->docs = $this->getData(); // where everything above is executed
if (!empty($this->docs)) {
//Sort documents by level for proper wrapper substitution
ksort($this->docs);
//for offsetChildren
//we are testing for offsetChildren's existence and then reordering the submenus for the adoptive parent in order to use our assigments ****
if($this->offsetChildren){
foreach($this->docs[2] AS $k=>&$v){
if(in_array($k, $this->offsetParents)){
//you need to reorder the subs based on menuindex
foreach($v AS $key => $row){
$order[$key] = $row['menuindex'];
}
array_multisort($order, SORT_ASC, $v);
}
}
}
//BACK TO NORMAL FUNCTION
//build the menu
return $this->buildMenu();
[...]