API:getParent
From MODx Wiki
Returns the parent record for the id passed.
Usage
array getParent($id=-1, $active=1, $fields='id, pagetitle, description, alias, parent');
Examples
$parent = $modx->getParent(55,1,'pagetitle');
will return the parent's pagetitle of the document 55 only if the parent is published.
$parent = $modx->getParent(55,0,'id');
will return parent document's id even if is not published.
Source Code
| File: | manager/includes/document.parser.class.inc.php |
|---|---|
| Line: | 1467 |
function getParent($pid= -1, $active= 1, $fields= 'id, pagetitle, description, alias, parent') { if ($pid == -1) { $pid= $this->documentObject['parent']; return ($pid == 0) ? false : $this->getPageInfo($pid, $active, $fields); } else if ($pid == 0) { return false; } else { // first get the child document $child= $this->getPageInfo($pid, $active, "parent"); // now return the child's parent $pid= ($child['parent']) ? $child['parent'] : 0; return ($pid == 0) ? false : $this->getPageInfo($pid, $active, $fields); } }