When i do this in my plugin, it crashes. The reason seems to be that the function cannot access the $modx. Is this piece of code wrong? (never mind small errors, the general idea). I just wanna check ifthe document belong to a specific parent.
function up($id,$top) {
$pid = $modx->getParent($id,1,’id’);
while ($pid[’id’] != $top) {
$id = $pid[’id’];
$pid = $modx->getParent($id,1,’id’);
if($pid[’id’] == $top) { return $id; }
}
};
$d = $modx->event->params[’id’];
//$parent = $modx->getParent($d,1,’pagetitle’);
system("mkdir /home/1471/domains/deloudis.gr/html/assets/images/ImageLib/".$d);
//$pid = $modx->getParent($id,1,’id’);
echo up($d,6);
return;
A so global $modx need to be defined. Thank you!