--- class.t3lib_befunc.php.ORIG 2007-03-06 00:52:30.000000000 +0100 +++ class.t3lib_befunc.php 2007-03-06 07:25:30.000000000 +0100 @@ -2792,10 +2792,32 @@ // rootLevel = -1 is not handled 'properly' here - it goes as if it was rootLevel = 1 (that is pid=0) $wgolParts = $GLOBALS['TYPO3_DB']->splitGroupOrderLimit($fTWHERE); + + // look for additional tables + $tablesArr = array($foreign_table); + $allTables = is_set($fieldValue['config'][$prefix.'foreign_table_additional'])?$fieldValue['config'][$prefix.'foreign_table_additional']:''; + $additional_tables = explode(',', $allTables); + + if (!$rootLevel && $foreign_table != 'pages') { + + foreach ($additional_tables as $i => $table) { + + if (substr_count($table, 'pages') > 0) { + unset($additional_tables[$i]); + } + + } + + $tablesArr[] = 'pages'; + } + + $tablesArr = array_unique(array_merge($tablesArr, $additional_tables)); + $tables = implode(',', $tablesArr); + if ($rootLevel) { $queryParts = array( 'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'), - 'FROM' => $foreign_table, + 'FROM' => $tables, 'WHERE' => $foreign_table.'.pid=0 '. t3lib_BEfunc::deleteClause($foreign_table).' '. $wgolParts['WHERE'], @@ -2808,7 +2830,7 @@ if ($foreign_table!='pages') { $queryParts = array( 'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'), - 'FROM' => $foreign_table.',pages', + 'FROM' => $tables, 'WHERE' => 'pages.uid='.$foreign_table.'.pid AND pages.deleted=0 '. t3lib_BEfunc::deleteClause($foreign_table). @@ -2821,7 +2843,7 @@ } else { $queryParts = array( 'SELECT' => t3lib_BEfunc::getCommonSelectFields($foreign_table,$foreign_table.'.'), - 'FROM' => 'pages', + 'FROM' => $tables, 'WHERE' => 'pages.deleted=0 AND '.$pageClause.' '. $wgolParts['WHERE'],