Show chunk based on Parent ID

I saw this on the old modx forum and I know there are probably a million different ways to do this. I thought this might help someone else down the road. Of course if anyone has a better way I am completely open to modify it!

<?php
 
/* ShowNav snippet

[[!NextPrev_Snip?  &parents=`8,9,11` &chunk=`nextPrevChk`]]

*/

// input from snippet for parent ids
$parentIds = explode(',', $parents);

// get parent id
$parentId = $modx->resource->get('parent');

// if there is a match show chunk otherwise hide
if (in_array($parentId, $parentIds)) {

    // get a custom chunk to output anything based on parent id
    $output = $modx->getChunk($chunk);
}

return $output;

The chunk can be anything, I used a chunk to with the snippet [[pdoNeighbors]] “prev / next” buttons.

I think you can read the parent id directly from the resource and don’t need to query the database:

$parentId = $modx->resource->get('parent');

Less is more, thank you @halftrainedharry! Updated to reflect.