This question has been answered by multiple community members. See the first response.
<?php
$id = $modx->getOption('resource_id', $_REQUEST, '');
$output = array();
if (!empty($id)) {
//if not a new resource
if ($collection = $modx->getCollection('modResource', array('parent' => $id))) {
foreach ($collection as $object) {
$output[] = $object->get('pagetitle') . '==' . $object->get('id');
}
}
}
return implode('||', $output);
@EVAL return $modx->runSnippet('getChildrenOptions');
How the tree looks:
- Parent 1
- Parent 2 (where TV has to be set)
- Child 1
- Child 2
- Child 3
- Parent 3
What I see in the dropdown:
- Parent 1
- Parent 2
- Parent 3
What I expected to see in the dropdown:
- Child 1
- Child 2
- Child 3
$output = '';
if ($object = $modx->getObject('modResource',$id)){
$output = $object->get('pagetitle');
}
return $output;[[getPagetitle? &id=`[[+yourResourceIdField]]`]]
