| 
                                                             Thursday 12 February 2004 8:07:18 am 
                                                            
                                                            
                                                                 Hi Ken, no, sorting by ParentID won't help. You have to implement a "getTree"-Class. Do something similar in the importfolder.php:         
class mytree
{
	var $data;
	var $table;
	var $ID;
	
	function mytree( $id=-1, $table = 'eZArticle_Category' )
    {
        if ( $id != -1 )
        {
            $this->ID = $id;
            $this->table = $table;
            $this->get( $this->ID, $table );
        }
    }
    
    function get( $id=-1, $table = 'eZArticle_Category')
    {
        if ( $id != "" )
        {
            $db =& eZDB::instance();
		    $db->setIsSQLOutputEnabled( false );
			$data = $db->arrayQuery( "SELECT *
			FROM
			  $table
		    WHERE ID = $id" );
			$this->data = $data;
        }
    }
    
    function id()
    {
    	return $this->ID;	
    }
    
    function getByParent( $parent, $table = "eZArticle_Category" )
    {
        if ( get_class( $parent ) == "mytree" )
        {
            $db =& eZDB::instance();
		    $db->setIsSQLOutputEnabled( false );
			
            $return_array = array();
            $category_array = array();
            $parentID = $parent->id();
            $show_str = "";
            
		    $query = "SELECT ID 
                      FROM $table 
                      WHERE ParentID='$parentID'
                      ORDER BY Name
                            ";
            $category_array = $db->arrayQuery( $query );
            for ( $i=0; $i < count($category_array); $i++ )
            {
                $return_array[$i] = new mytree( $category_array[$i]["ID"], $table );
            }
            return $return_array;
        }
        else
        {
            return 0;
        }
    }
    
	function getTree( $table = "eZArticle_Category", $parentID=0, $level=0   )
	{
	    if ( get_class( $parentID ) == "mytree" )
	        $category = $parentID;
	    else
	        $category = new mytree( $parentID, $table );
	
	    $categoryList = $category->getByParent( $category, $table );
	
	    $tree = array();
	    $level++;
	    foreach ( $categoryList as $category )
	    {
	        array_push( $tree, array( $return_array[] = $category, $level ) );
	
	        if ( $category != 0 )
	        {
	            $tree = array_merge( $tree, mytree::getTree( $table, $category, $level  ) );
	        }
	    }
	    return $tree;
	}
}
(...)
    Alter the function "folderList":         
function folderList($table = 'eZArticle_Category'  )
{
    $tree = mytree::getTree($table);
    $folderArray = array();
    foreach ($tree as $item)
    {
    	$folderArray[] = $item[0]->data[0];
    }
	return $folderArray;
}
    To get the sorted folders:         
$articleFolderList =& folderList('eZArticle_Category' );
    $imageFolderList =& folderList('eZImageCatalogue_Category' ); (and so on)                                                             
                                                                                                                            Best wishes, 
Georg. 
 
-- 
http://www.schicksal.com Horoskop website which uses eZ Publish since 2004
                                                                 
                                                                                                                                                                                 |