[[getResources? &parents=`[[*id]]` &tplFirst=`gR_bodListItem1st` &tpl=`gR_bodListItem` &tplLastt=`gR_bodListItemLast` &includeTVs=`1` &sortby=`{"menuindex":"ASC","publishedon":"DESC"}` &showHidden=`1` &includeContent=`1` &hideContainers =`0` ]]<ul> [[$gR_bodListItem]]
[[+isfolder:eq=`1`:then=`<h2>[[getResourceField ? &id=`[[+parent]]` &field=`pagetitle`]]</h2>`]]
<li>
[[+isfolder:eq=`1`
:then=`[[!getResources? &parents=`[[+id]]` &tplFirst=`gR_bodListItem1st` &tpl=`gR_bodListItem` &tplLast=`gR_bodListItemLast` &includeTVs=`1` &sortby=`{"menuindex":"ASC","publishedon":"DESC"}` &showHidden=`1` &includeContent=`1`]]`
:else=`
... staff member content, etc ...
` ]]
</li>[[$gR_bodListItem]] </ul>
[[!ShowStaff]]
<?php
/* ShowStaff snippet */
$departments = $modx->resource->getMany('Children');
$output = '<h2>' . $modx->resource->get('pagetitle') . '</h2>';
if (empty($departments)) {
$output .= ' No Departments';
} else {
foreach ($departments as $department) {
$output .= "\n<h3>" . $department->get('pagetitle') . '</h3>';
$employees = $department->getMany('Children');
if (empty($employees)) {
$output .= "\n No Employees";
} else {
foreach ($employees as $employee) {
$fields = $employee->toArray();
$output .= $modx->getChunk('employeeTpl', $fields);
}
}
}
}
$output .= '<ul>';
<?php
if (! $department->get('isfolder')) {
/* it's an employee */
}[[+FieldName]]
<?php
$fields['FieldName'] = $employee->getTVValue('TvName');
<?php
/* ShowStaff snippet */
// Get children below snippet
$departments = $modx->resource->getMany('Children');
$output = '<ul class="bodul">';
// if no children
if (empty($departments)) {
$output .= "\n\t<li>No Departments\</li>";
} else {
foreach ($departments as $department) {
// if not published, go to next resource
if (!$department->get('published')) continue;
// if resource is container, output pagetitle and trawl for children
if ($department->get('isfolder')) {
$output .= "\n\t<li>\n\t\t<ul>";
$output .= "\n\t\t\t<li><h3>" . $department->get('pagetitle') . "</h3></li>\n";
$employees = $department->getMany('Children');
if (empty($employees) ) {
$output .= "\n\t\t\t<li>No Employees</li>";
} else {
foreach ($employees as $employee) {
if (!$employee->get('published')) continue;
$fields = $employee->toArray();
$fields['tv.bodTitle'] = $employee->getTVValue('bodTitle');
$fields['tv.bodQuals'] = $employee->getTVValue('bodQuals');
$fields['tv.bodEmail'] = $employee->getTVValue('bodEmail');
$fields['tv.bodNumber'] = $employee->getTVValue('bodNumber');
$fields['tv.bodImage'] = $employee->getTVValue('bodImage');
$output .= $modx->getChunk('employeesTpl', $fields);
}
}
$output .= "\n\t\t</ul>\n\t</li>";
} else {
// if resource is not a container, extract data
$fields = $department->toArray();
$fields['tv.bodTitle'] = $department->getTVValue('bodTitle');
$fields['tv.bodQuals'] = $department->getTVValue('bodQuals');
$fields['tv.bodEmail'] = $department->getTVValue('bodEmail');
$fields['tv.bodNumber'] = $department->getTVValue('bodNumber');
$fields['tv.bodImage'] = $department->getTVValue('bodImage');
$output .= $modx->getChunk('employeesTpl', $fields);
}
}
}
$output .= "\n</ul>";
return $output;<?php
$c = $xpdo->newQuery('modResource');
$c->sortby('pagetitle','ASC');
$departments = $modx->resource->getMany('Children', $c);
$scriptProperties['propertyName']
$_POST['fieldName']