documentObject['parent']; // (re)set the $id variable to the one of this document. $id = $modx->documentIdentifier; // select the other members in this folder $children = $modx->getActiveChildren($parentid, $sortBy, $sortHow); // the number of selected documents $limit = count($children); // set $y to zero $y = 1; // sorting the documents, giving them a sequential and searchable index foreach ($children as $child) { $my_array[$y] = $child; if ($my_array[$y]['id']==$id){ $current=$y; // The current page has number $y in the array } $y++; } $prev = $current-1; $next = $current+1; // if &direction is set to 1 do this if ($direction == 1) { if ($prev == 0) { // in case a value previous to the first document return $pntext; } else { // get the id of the previous document $previd = $my_array[$prev]['id']; // return the output of the TV named in the Snippet call -> tvname ($pntv) $document_tvs = $modx->getTemplateVarOutput(true, $previd); $templatevar_output = $document_tvs[$pntv]; $output = $templatevar_output; return $output; } } // if &direction is set to 2 do this elseif ($direction == 2) { if ($current == $limit) { // in case a value next to the last document return $pntext; } else { // get the id of the next document $nextid = $my_array[$next]['id']; // return the output of the TV named in the Snippet call -> tvname ($pntv) $document_tvs = $modx->getTemplateVarOutput(true, $nextid); $templatevar_output = $document_tvs[$pntv]; $output = $templatevar_output; return $output; } } else { $output = ''; return $output; } ?>