Advertisement
vanchelo

getResourceChildren

Feb 8th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. /**
  2.  * [getResourceChildren description]
  3.  * @param  integer $id Container ID
  4.  * @return array An array of container children
  5.  */
  6. function getResourceChildren($id) {
  7.     $result = array();
  8.     $success = false;
  9.     $q = $modx->newQuery('modResource');
  10.     $q->where(array('parent' => $id, 'deleted' => false, 'published' => true));
  11.     $q->select(array('id','pagetitle','uri'));
  12.     $q->sortby('pagetitle','ASC');
  13.  
  14.     if ($q->prepare() && $q->stmt->execute()) {
  15.         $result = $q->stmt->fetchAll(PDO::FETCH_ASSOC);
  16.         if (count($result)) $success = true;
  17.     }
  18.  
  19.     return $success ? $result : $success;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement