Reputation: 11
I'm a noob in the modx world. I have a page with subpages and I using getResources to display the content of those in tabs on the parent page.
What I would like to do is only display that chunk if the parent has subpages?
So something like this, but this is obviously not right because its not working.
[[!getResources &parent:notempty=`[[$chunk]]`]]
Upvotes: 1
Views: 1958
Reputation: 831
it's &parents , with "s".
Anyway, If you want to use output filter for snippet, you add it BEFORE the question mark:
[[!getResources:isempty=`No content is available`? &parents =`[[*id]]`]]
Upvotes: 0
Reputation: 4494
Give this a shot, create a new snippet for this;
<?php
// get the current resource id
$id = $modx->resource->get('id');
// get the resource object
$resource = $modx->getObject('modResource', $docId);
// make sure we have a resource
if($resource){
// see if the resource has children
$hasChildren = $resource->hasChildren();
if($hasChildren){ // pretty sure hasChildren returns 1 or 0
// optionally, retrieve the chunk & populate it.
// replace your-chunk-name and the placeholders with your values.
$output = $modx->getChunk('your-chunk-name',array(
'placeholder-1-name' => 'value',
'placeholder-2-name' => 'value',
'placeholder-3-name' => 'value',
'placeholder-4-name' => 'value',
));
return $output;
}
}
return true;
Upvotes: 0