Skip to content

Instantly share code, notes, and snippets.

@qwertik17
Created June 3, 2019 07:05
Show Gist options
  • Select an option

  • Save qwertik17/952860ab83903cd7601f28084fdc75c5 to your computer and use it in GitHub Desktop.

Select an option

Save qwertik17/952860ab83903cd7601f28084fdc75c5 to your computer and use it in GitHub Desktop.
Get parent tv for modx revo
<?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