This question has been answered by nickyz. See the first response.
I don't think you'll find a way to do this with an existing extra. I think you'll need a custom snippet.[ed. note: nickyz last edited this post 7 years, 6 months ago.]
I was going to suggest some code, but I'm confused by your description of what you want to do.
I'm probably just being dense, but your specifications seem to contradict each other:
"I want to list only the parent(s) and its children"
"no parent should be listed"
"the relevant parent must be listed"
"I don't want to list the children, only the parents"
It's not clear to me when those various rules apply.
/* Discontinued Plugin */ $tvId = 12; // change this to the ID of the TV holding the 1 if ($resource->getTVValue($tvID) == 1) { $resource->set('donthit', '1'); $resource->save(); }
$output = ''; $parentArray = array(); $disField = 'donthit'; $docs = $modx->getCollection('modResource', array($disField => 1)); foreach ($docs as $doc) { $parentId = (int) $doc->get('parent'); $parentObj = $modx->getObject('modResource', $parentId); $parentPagetitle = $parentObj->get('pagetitle'); if (! in_array($parentPageTitle, $parentArray)) { $parentArray[] = $parentPagetitle; } } /* Put them in alphabetical order */ natcasesort($parentArray); /* create the output */ $output = '<ul>'; foreach($parentArray as $pagetitle) { $output .= '<li class="disItem">' . $pagetitle . '</li>'; } $output .= '</ul>'; return $output;
[[pdoResources:default=``? &parents=`[[UltimateParent]]` &depth=`1` &includeContent=`0` &tpl=`CategoryListerItemDP` &templates=`6` &limit=`0` &showHidden=`0` &sortby=`{"pagetitle":"ASC"}` ]]
[[pdoResources:default=``? &parents=`[[+id]]` &includeContent=`0` &includeTVs=`DiscProd` &tpl=`@INLINE [[+idx]]` &templates=`7` &tvFilters=`DiscProd==1` &limit=`1` &showHidden=`0` &sortby=`{"pagetitle":"ASC"}` &toPlaceholder=`catsDP` ]] [[!If? &subject=`[[+catsDP]]` &operator=`GT` &operand=`0` &then=`<h2 class="redcolor">[[+pagetitle]]:</h2><ul class="clearfix">[[!$prodDP? &idp=`[[+id]]`]]</ul>` &else=`` ]]