Index: trunk/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r8491 -r8562 --- trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 8491) +++ trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 8562) @@ -141,9 +141,15 @@ if ("$parent_cat_id" != 'any') { if ($event->getEventParam('recursive')) { - $current_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$parent_cat_id); - $subcats = $this->Conn->GetCol('SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE ParentPath LIKE "'.$current_path.'%" '); - $object->addFilter('parent_filter', 'ParentId IN ('.implode(', ', $subcats).')'); + if ($parent_cat_id > 0) { + // not "Home" category + $sql = 'SELECT TreeLeft, TreeRight + FROM '.TABLE_PREFIX.'Category + WHERE CategoryId = '.$parent_cat_id; + $tree_indexes = $this->Conn->GetRow($sql); + + $object->addFilter('parent_filter', TABLE_PREFIX.'Category.TreeLeft BETWEEN '.$tree_indexes['TreeLeft'].' AND '.$tree_indexes['TreeRight']); + } } else { $object->addFilter('parent_filter', 'ParentId = '.$parent_cat_id); Index: trunk/core/units/general/cat_event_handler.php =================================================================== diff -u -N -r8546 -r8562 --- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 8546) +++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 8562) @@ -360,9 +360,15 @@ if ((string) $parent_cat_id != 'any') { if ($event->getEventParam('recursive')) { - $current_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$parent_cat_id); - $subcats = $this->Conn->GetCol('SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE ParentPath LIKE "'.$current_path.'%" '); - $object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId IN ('.implode(', ', $subcats).')'); + if ($parent_cat_id > 0) { + // not "Home" category + $sql = 'SELECT TreeLeft, TreeRight + FROM '.TABLE_PREFIX.'Category + WHERE CategoryId = '.$parent_cat_id; + $tree_indexes = $this->Conn->GetRow($sql); + + $object->addFilter('category_filter', TABLE_PREFIX.'Category.TreeLeft BETWEEN '.$tree_indexes['TreeLeft'].' AND '.$tree_indexes['TreeRight']); + } $object->addFilter('primary_filter', 'PrimaryCat = 1'); } else { Index: trunk/core/units/categories/categories_config.php =================================================================== diff -u -N -r8397 -r8562 --- trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 8397) +++ trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 8562) @@ -251,6 +251,8 @@ 'CreatedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => 0), 'ResourceId' => Array('type' => 'int', 'default' => null), 'ParentPath' => Array('type' => 'string', 'default' => null), + 'TreeLeft' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), + 'TreeRight' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'NamedParentPath' => Array('type' => 'string', 'default' => null), 'MetaDescription' => Array('type' => 'string', 'default' => null), 'HotItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),