[Typo3-dev] finding subpages

Elmar Hinz elmar.hinz at vcd-berlin.de
Fri Apr 8 15:33:46 CEST 2005


Elmar Hinz wrote:
> Hello,
> 
> does any function exists to find all subpages (list of uids) of a 
> special page?
> 
> Regards
> 
> Elmar
> 
> 

This function finds a list of sucessors and includes the node itself:

   function getChildrenAndSelf($uid){
     $pages = array($uid) ;
     $qClause = 'pid='.$uid.t3lib_BEfunc::deleteClause('pages');
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 'uid', 'pages', 
$qClause );
     while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
       $pages =   array_merge( $pages, 
$this->getChildrenAndSelf($row['uid']));
     }
     return $pages;
   }



This function filters the acessible pages out of the given list for the 
current BE-User:

   function filterUserEditablePages($pages){
     global $BE_USER;
     $array = array();
     foreach($pages as $uid)   $uidClause .= ' OR uid='.$uid;
     $uidClause = substr($uidClause, 3);
     $clause = '  '.$uidClause.t3lib_BEfunc::deleteClause('pages');
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( '*', 'pages', $clause );
     while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
       if($BE_USER->doesUserHaveAccess($row, 2)) $array[] = $row['uid'];
     }
     return $array;
   }





More information about the TYPO3-dev mailing list