Created
November 30, 2018 00:59
-
-
Save dubrod/3d64b69f945bc10743a51df63dfebb4a to your computer and use it in GitHub Desktop.
simple ultimate parent title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//4 levels deep | |
$title = ''; | |
//first level parent | |
$parentId = $modx->resource->get('parent'); | |
if($parentId == 0){ | |
$title = $modx->parseChunk('interior-title', array('title' => $modx->resource->get('pagetitle') )); | |
return $title; | |
} else { | |
//its not the root, go again | |
$parentObj = $modx->getObject('modResource', $parentId); | |
$gId = $parentObj->get('parent'); | |
} | |
if($gId == 0){ | |
$title = $modx->parseChunk('interior-title', array('title' => $parentObj->get('pagetitle') )); | |
return $title; | |
} else { | |
//its not the root, go again | |
$gObj = $modx->getObject('modResource', $gId); | |
$ggId = $gObj->get('parent'); | |
} | |
if($ggId == 0){ | |
$title = $modx->parseChunk('interior-title', array('title' => $gObj->get('pagetitle') )); | |
return $title; | |
} else { | |
//its not the root, go again | |
$ggObj = $modx->getObject('modResource', $ggId); | |
$gggId = $ggObj->get('parent'); | |
} | |
if($gggId == 0){ | |
$title = $modx->parseChunk('interior-title', array('title' => $ggObj->get('pagetitle') )); | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment