Created
November 30, 2018 00:40
-
-
Save dubrod/a0ee8e1dc2941e21c5f0b87064efe919 to your computer and use it in GitHub Desktop.
collection of modx parent snippets
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
GetParentAlias | |
$output = ''; | |
/* Get the current resource's 'parent' field */ | |
$parentId = $modx->resource->get('parent'); | |
/* Get the parent object */ | |
$parentObj = $modx->getObject('modResource', $parentId); | |
/* If we have the parent, | |
get and return the alias */ | |
if ($parentObj) { | |
$output = $parentObj->get('alias'); | |
} | |
return $output; | |
----- | |
GetParentPagetitle | |
$output = ''; | |
/* Get the current resource's 'parent' field */ | |
$parentId = $modx->resource->get('parent'); | |
/* Get the parent object */ | |
$parentObj = $modx->getObject('modResource', $parentId); | |
/* If we have the parent, | |
get and return the pagetitle */ | |
if ($parentObj) { | |
$output = $parentObj->get('pagetitle'); | |
} | |
return $output; | |
----- | |
<?php | |
$output = ''; | |
$id = $modx->getOption('id', $scriptProperties); | |
$idObj = $modx->getObject('modResource', $id); | |
$parentId = $idObj->get('parent'); | |
$parentObj = $modx->getObject('modResource', $parentId); | |
$gId = $parentObj->get('parent'); | |
$gObj = $modx->getObject('modResource', $gId); | |
if ($gObj) {$output = $gObj->get('pagetitle');} | |
return $output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment