Created
June 3, 2019 07:05
-
-
Save qwertik17/952860ab83903cd7601f28084fdc75c5 to your computer and use it in GitHub Desktop.
Get parent tv for modx revo
This file contains hidden or 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 | |
| if (!$tv) return; | |
| $tv_value = $modx->resource->getTVvalue($tv); | |
| if (!$tv_value) { | |
| $catalog_sections = false; | |
| $parents_array = $modx->getParentIds($modx->resource->id); | |
| foreach ($parents_array as $parent) { | |
| if ($parent !== 0) { | |
| $obj = $modx->getObject('modResource',$parent); | |
| $tv_value = $obj->getTVvalue($tv); | |
| if ($tv_value) break; | |
| } | |
| } | |
| } | |
| if ($tv_value) { | |
| if ($toPlaceholder) { | |
| $modx->setPlaceholder($toPlaceholder, $tv_value); | |
| return; | |
| } | |
| return $tv_value; | |
| } | |
| return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment