Skip to content

Instantly share code, notes, and snippets.

@pavel-one
Created July 16, 2018 17:20
Show Gist options
  • Save pavel-one/8018aefa3493afd5750f3dc1f38a10ea to your computer and use it in GitHub Desktop.
Save pavel-one/8018aefa3493afd5750f3dc1f38a10ea to your computer and use it in GitHub Desktop.
<?php
function getParents($id) {
global $modx;
$out = '';
$arr = array();
for ($i=0; $i<99; $i++) {
$parId = $modx->getObject('modResource', $id)->get('parent');
$parentRes = $modx->getObject('modResource', $parId);
if (!$parentRes) {
$out = 'Fake';
break;
}
$parentId = $parentRes->get('id');
if ($parentId != 3) {
$pagetitile = $parentRes->get('pagetitle');
$arr[] = $pagetitile;
//echo $pagetitile;
$id = $parentId;
} else {
//print_r($arr);
$arr = array_reverse($arr);
$out = implode('|', $arr);
break;
}
}
return $out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment