Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(TOOLKIT . '/class.datasource.php');
- Class datasourceget_child_contentpages extends Datasource{
- public $dsParamROOTELEMENT = 'sub-content-pages';
- public function about(){
- return array(
- 'name' => 'Get Child Contentpages',
- 'author' => array(
- 'name' => 'David Hund',
- 'email' => 'david@valuedstandards.com'),
- );
- }
- public function getSource(){
- return '1';
- }
- public function grab(&$param_pool){
- $result = new XMLElement($this->dsParamROOTELEMENT);
- $parentPageId = $this->_env['param']['current-page-id'];
- // Set param: $child-content-pages that contains all handle's of sub-ContentPages
- // We need handles because we use a Pages Field
- // taken from: http://tech.carsonsasser.com/article/how-to-pre-enter-author-data-in-comment-form
- $query = "SELECT handle FROM sym_pages WHERE parent = ".$parentPageId." ORDER BY sortorder ASC";
- $pagechildren = $this->_Parent->Database->fetch( $query );
- $children = array();
- $count = 0;
- foreach($pagechildren as $child){ $children[] = $pagechildren[$count]["handle"]; $count++; }
- $param_pool['child-content-pages'] = $children;
- // OPTIONALLY: Create XML of subpages
- // $query = "SELECT * FROM sym_pages WHERE parent = ".$parentPageId." ORDER BY sortorder ASC";
- // $pagechildren = $this->_Parent->Database->fetch( $query );
- // foreach($pagechildren as $child){
- // $child_node = new XMLElement("page", $child["title"]);
- // $child_node->setAttributeArray(array("handle" => $child["handle"], "id" => $child["id"]));
- // $result->appendChild($child_node);
- // }
- // return $result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement