I need a little snippet that checks if the parent of an document is 0. Neither UltimateParent doesn´t seem to fit because it will return the doc´s ID if the parent is 0 nor GetParent (the snippet).
So I wrote this little piece of code for a snippet.
$id = $modx->documentIdentifier;
$topid = $modx->getParent($id,1,'id');
return $topid;
Unfortunately it doesn´t return anything when it is put to a document of the first level and "Array" when it will be called from a seceond level document. What´s wrong with the snippet?
Or is there a way to find out if an document is an grandchild in a site structure like this.
Site root (id 0)
- Home
- foo
- grandchild
Thank you for any suggestion.