/**
* childOf
* Ouput filter to determine if the current resource is a child of another.
* Example use: [[*id:childOf=`69`]] would determine if current resource is a child of resource 69
*
*/
$id = (!empty($input)) ? $input : false;
if(!empty($id)) { $id = $modx->getOption('id', $scriptProperties, $modx->resource->get('id')); }
$thisResourceId = $modx->resource->get('id');
// get the published children of $id
$c = $modx->newQuery('modResource');
$c->where(array(
'parent' => $id,
'published' => true
));
$c->sortby('menuindex', 'ASC');
$children = $modx->getCollection('modResource',$c);
foreach ($children as $child) {
$childId = $modx->getObject('modResource', $child);
if(!empty($child) && $childId == $thisResourceId ) {
return true;
}
}
return false;[[*id:childOf=`20`:then=`[[+pagetitle=`Clients`]]`]]
This question has been answered by sottwell. See the first response.
[[[[*parent:is=`20`:then=`Client`:else=`*pagetitle`]]]]
<?php
$parent = $modx->resource->get('parent');
switch ($parent) {
case 20:
$output = 'Clients';
break;
default:
$output = $modx->resource->get('pagetitle');
break;
}
return $output;
[[[[#[[*parent]].tv.title:is=``:then=`*pagetitle`]]]]
$parentObj = $modx->getObject('modResource', $modx->resource->get('parent'));
return $parentObj? $parentObj->get('pagetitle') : '';$childId = $modx->getObject('modResource', $child);$childId = $child->get('id');$id = isset($options)? $options : $modx->resource->get('id');[[[[*parent:is=`20`:then=`Client`:else=`*pagetitle`]]]]
[[*id:childOf=`69`]]
return (isset($options) && ($modx->resource->get('parent') == $options))? true : false;[[*id:ne=`1`:then=`<h1 class="page-header">[[*parent:is=`20`:then=`Clients`:else=`*pagetitle`]] > <span class="text-orange"> [[*longtitle]]</span></h1>`]]
From what I understand, what is wanted is to use the current resource's 'pagetitle' if the parent is not #20, but to use "Clients" if its parent is #20. The parent's pagetitle is not relevant.
[[!PageHeader]]
/* PageHeader snippet */
if ($modx->resource->get('id') == 1) return;
$output = '<h1 class="page-header">';
$output .= $modx->resource->get('parent') == 20? 'Clients' : $modx->resource->get('pagetitle');
$output .= '<span class="text-orange">';
$output .= $modx->resource->get('longtitle') . '</span></h1>';
return $output;