Answer the question
In order to leave comments, you need to log in
How to display the daughters of the desired resource modx api + ajax?
What am I trying to do?
There is a tree
-Родитель1 --дочка1 --дочка2
-Родитель2 --дочка1 --дочка2 --дочка2...
$res = $modx->getObject('modResource', $_POST['id']);
return $res->getMany('Children');
$('.inpts select#brand').on('change',function(e){
var id = $(this).find('option:selected').attr('data-id');
$.ajax({
type: "POST",
url: "content.html",
data: "id="+id,
success: function(content){
$(".inpts").html(content);
}
});
});
Answer the question
In order to leave comments, you need to log in
If someone helps.
$res = $modx->getObject('modResource', $_POST['id']);
$id = $res->get('id');
$depth = 1;
$ids = $modx->getChildIds($id, $depth);
$docs = $modx->getCollection('modResource', array(
'id:IN' => $ids
,'alias:!=' => 'f'
));
$output = '';
foreach ($docs as $doc) {
$output .= $doc->get('pagetitle') . '<br/>';
}
return $output;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question