Index: branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php =================================================================== diff -u -r5905 -r5908 --- branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php (.../application.php) (revision 5905) +++ branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php (.../application.php) (revision 5908) @@ -517,13 +517,16 @@ $this->setCache('item_templates', $id, $category_data['CachedItemTemplate']); } else { - - $resource_id = $this->Conn->GetOne('SELECT ResourceId FROM '.$table.' WHERE '.$id_field.' = '.$this->Conn->qstr($id)); if (is_null($category_id)) $category_id = $this->GetVar('m_cat_id'); $sql = 'SELECT Filename FROM '.TABLE_PREFIX.'CategoryItems WHERE ItemResourceId = '.$resource_id.' AND CategoryId = '.$category_id; $filename = $this->Conn->GetOne($sql); + if (!$filename) { + $sql = 'SELECT Filename FROM '.TABLE_PREFIX.'CategoryItems WHERE ItemResourceId = '.$resource_id.' AND PrimaryCat = 1'; + $filename = $this->Conn->GetOne($sql); + } + /*$sql = 'SELECT Filename FROM '.$table.' WHERE '.$id_field.' = '.$this->Conn->qstr($id);