Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2011
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <?php
  2.  
  3. require_once(TOOLKIT . '/class.datasource.php');
  4.  
  5. Class datasourceget_child_contentpages extends Datasource{
  6.  
  7.     public $dsParamROOTELEMENT = 'sub-content-pages';
  8.  
  9.     public function about(){
  10.         return array(
  11.                  'name' => 'Get Child Contentpages',
  12.                  'author' => array(
  13.                         'name' => 'David Hund',
  14.                         'email' => 'david@valuedstandards.com'),
  15.                 );
  16.     }
  17.  
  18.     public function getSource(){
  19.         return '1';
  20.     }
  21.  
  22.     public function grab(&$param_pool){
  23.         $result = new XMLElement($this->dsParamROOTELEMENT);
  24.  
  25.         $parentPageId = $this->_env['param']['current-page-id'];
  26.  
  27.         // Set param: $child-content-pages that contains all handle's of sub-ContentPages
  28.         // We need handles because we use a Pages Field
  29.         // taken from: http://tech.carsonsasser.com/article/how-to-pre-enter-author-data-in-comment-form
  30.         $query = "SELECT handle FROM sym_pages WHERE parent = ".$parentPageId." ORDER BY sortorder ASC";
  31.         $pagechildren = $this->_Parent->Database->fetch( $query );
  32.         $children = array();
  33.         $count = 0;
  34.         foreach($pagechildren as $child){ $children[] = $pagechildren[$count]["handle"]; $count++; }
  35.         $param_pool['child-content-pages'] = $children;
  36.  
  37.         // OPTIONALLY: Create XML of subpages
  38.         // $query = "SELECT * FROM sym_pages WHERE parent = ".$parentPageId." ORDER BY sortorder ASC";
  39.         // $pagechildren = $this->_Parent->Database->fetch( $query );
  40.         // foreach($pagechildren as $child){
  41.           // $child_node = new XMLElement("page", $child["title"]);
  42.           // $child_node->setAttributeArray(array("handle" => $child["handle"], "id" => $child["id"]));
  43.           // $result->appendChild($child_node);
  44.         // }
  45.         // return $result;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement