2013-08-06 2 views
1

저는 modx 세계에서 멍청한 사람입니다. 서브 페이지가있는 페이지가 있고 getResources를 사용하여 상위 페이지의 탭에있는 내용을 표시합니다.getResources parent가 비어 있지 않은 경우 디스플레이 청크

부모님 께 서브 페이지가있는 경우에만 청크를 표시하고 싶습니다.

이렇게 뭔가가 있지만 분명히 옳지 않습니다. 작동하지 않기 때문입니다.

[[!getResources &parent:notempty=`[[$chunk]]`]] 

답변

0

이 장면에 새로운 스 니펫을 만듭니다.

<?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; 
0

부모는 "s"입니다. 당신이 조각의 출력 필터를 사용하려면

어쨌든, , 당신은 물음표 전에 추가 :

[[!getResources:isempty=`No content is available`? &parents =`[[*id]]`]] 
관련 문제