}
            $oPage->appendChild($xTypes);
        }
        if ($children = $database->fetch("SELECT * FROM `tbl_pages` WHERE `parent` = '" . $page['id'] . "' ORDER BY `sortorder` ASC")) {
            foreach ($children as $c) {
                $oPage->appendChild(__buildPageXML($c, $database));
            }
        }
        return $oPage;
    }
}
### BEGIN XML GENERATION CODE ###
$result = new XMLElement($this->dsParamROOTELEMENT);
$types = $parent_sql = null;
if (trim($this->dsParamFILTERS['type']) != '') {
    $types = __processNavigationTypeFilter($this->dsParamFILTERS['type'], Symphony::Database(), $this->__determineFilterType($this->dsParamFILTERS['type']));
}
if (trim($this->dsParamFILTERS['parent']) != '') {
    $parent_sql = __processNavigationParentFilter($this->dsParamFILTERS['parent']);
}
$sql = "SELECT DISTINCT p.* FROM `tbl_pages` AS p LEFT JOIN `tbl_pages_types` AS pt ON(p.id = pt.page_id) WHERE 1 = 1";
if (!is_null($parent_sql)) {
    $sql .= $parent_sql;
} else {
    $sql .= " AND p.parent IS NULL ";
}
if (!is_null($types)) {
    $sql .= " AND pt.type IN ('" . implode("', '", $types) . "')";
}
$sql .= " ORDER BY p.`sortorder` ASC";
$pages = Symphony::Database()->fetch($sql);
            $xTypes = new XMLElement('types');
            foreach ($types as $type) {
                $xTypes->appendChild(new XMLElement('type', $type));
            }
            $oPage->appendChild($xTypes);
        }
        if ($children = $database->fetch("SELECT * FROM `tbl_pages` WHERE `parent` = '" . $page['id'] . "' ORDER BY `sortorder` ASC")) {
            foreach ($children as $c) {
                $oPage->appendChild(__buildPageXML($c, $database));
            }
        }
        return $oPage;
    }
}
### BEGIN XML GENERATION CODE ###
$result = new XMLElement($this->dsParamROOTELEMENT);
if (trim($this->dsParamFILTERS['type']) != '') {
    $types = __processNavigationTypeFilter($this->dsParamFILTERS['type'], $this->_Parent->Database, $this->__determineFilterType($this->dsParamFILTERS['type']));
}
$sql = "SELECT * FROM `tbl_pages` \r\n\t\t\tWHERE " . (NULL != ($parent_sql = __processNavigationParentFilter($this->dsParamFILTERS['parent'])) ? $parent_sql : '`parent` IS NULL') . "\r\n\t\t\t" . ($types != NULL ? " AND `id` IN ('" . @implode("', '", $types) . "') " : NULL) . "\r\n\t\t \tORDER BY `sortorder` ASC";
$pages = $this->_Parent->Database->fetch($sql);
if (!is_array($pages) || empty($pages)) {
    if ($this->dsParamREDIRECTONEMPTY == 'yes') {
        $this->__redirectToErrorPage();
    }
    $result->appendChild($this->__noRecordsFound());
} else {
    foreach ($pages as $p) {
        $result->appendChild(__buildPageXML($p, $this->_Parent->Database));
    }
}
            }
            $oPage->appendChild($xTypes);
        }
        if ($children = Symphony::Database()->fetch("SELECT * FROM `tbl_pages` WHERE `parent` = '" . $page['id'] . "' ORDER BY `sortorder` ASC")) {
            foreach ($children as $c) {
                $oPage->appendChild(__buildPageXML($c, $page_types));
            }
        }
        return $oPage;
    }
}
### BEGIN XML GENERATION CODE ###
$result = new XMLElement($this->dsParamROOTELEMENT);
$type_sql = $parent_sql = null;
if (trim($this->dsParamFILTERS['type']) != '') {
    $type_sql = __processNavigationTypeFilter($this->dsParamFILTERS['type'], $this->__determineFilterType($this->dsParamFILTERS['type']));
}
if (trim($this->dsParamFILTERS['parent']) != '') {
    $parent_sql = __processNavigationParentFilter($this->dsParamFILTERS['parent']);
}
// Build the Query appending the Parent and/or Type WHERE clauses
$pages = Symphony::Database()->fetch(sprintf("\n\t\t\tSELECT DISTINCT p.*\n\t\t\tFROM `tbl_pages` AS p\n\t\t\tLEFT JOIN `tbl_pages_types` AS pt ON (p.id = pt.page_id)\n\t\t\tWHERE 1 = 1\n\t\t\t%s\n\t\t\t%s\n\t\t\tORDER BY p.`sortorder` ASC\n\t\t", !is_null($parent_sql) ? $parent_sql : " AND p.parent IS NULL ", !is_null($type_sql) ? $type_sql : ""));
if (!is_array($pages) || empty($pages)) {
    if ($this->dsParamREDIRECTONEMPTY == 'yes') {
        throw new FrontendPageNotFoundException();
    }
    $result->appendChild($this->__noRecordsFound());
} else {
    // Build an array of all the types so that the page's don't have to do
    // individual lookups.
    $types = Symphony::Database()->fetch("SELECT `page_id`,`type` FROM `tbl_pages_types`");