API:getParent
From MODx Wiki
Returns the parent record for the id passed.
[edit]
Usage
array getParent($id=-1, $active=1, $fields='id, pagetitle, description, alias, parent');
[edit]
Examples
$parent = $modx->getParent(55,1,'pagetitle');
will return the title of the parent of document 55 if the parent is published.
$parent = $modx->getParent(55,0,'id');
will return the parent document's id if it is not published.
From: http://modxcms.com/getparent.html
[edit]
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); } }
