Index: branches/5.2.x/core/units/helpers/category_helper.php =================================================================== diff -u -N -r15012 -r15042 --- branches/5.2.x/core/units/helpers/category_helper.php (.../category_helper.php) (revision 15012) +++ branches/5.2.x/core/units/helpers/category_helper.php (.../category_helper.php) (revision 15042) @@ -1,6 +1,6 @@ _primaryLanguageId; - $ret = Array($parent_category_id => str_repeat('-', $level).' '.$data['l' . $category_language . '_Name']); + $ret = Array($parent_category_id => str_repeat('—', $level).' '.$data['l' . $category_language . '_Name']); if ($data['children']) { $level++; @@ -411,8 +411,8 @@ $fields[] = 'l' . $language_id . '_Name'; } - $sql = 'SELECT CategoryId AS id, ' . implode(', ', $fields) . ', ParentId, ThemeId - FROM ' . $this->Application->getUnitOption('c', 'TableName') . ' + $sql = 'SELECT CategoryId AS id, ' . implode(', ', $fields) . ', ParentId, Template, ThemeId + FROM ' . TABLE_PREFIX . 'Categories ORDER BY Priority DESC'; $items = $this->Conn->Query($sql, 'id'); @@ -428,6 +428,16 @@ $parent_mapping[$item_id] = $item_parent_id; $items_by_parent[$item_parent_id][$item_id] = $item_data; } + + $base_category = $this->Application->getBaseCategory(); // "Content" category + $index_category = $this->findIndexCategoryId($items_by_parent[$base_category]); + + // rename "Content" into "Home" keeping it's ID + $items_by_parent[ $parent_mapping[$base_category] ][$base_category]['l1_Name'] = $this->Application->Phrase('la_rootcategory_name'); + + // remove category of "index.tpl" template + unset($items_by_parent[$base_category][$index_category]); + unset($parent_mapping[$index_category]); } $data = $items_by_parent[ $parent_mapping[$parent_category_id] ][$parent_category_id]; @@ -445,6 +455,17 @@ return $data; } + function findIndexCategoryId($top_categories) + { + foreach ($top_categories as $category_id => $category_info) { + if ($category_info['Template'] == 'index') { + return $category_id; + } + } + + return false; + } + /** * Generates OR retrieves from cache structure tree * @@ -580,10 +601,9 @@ $data = $this->_getStructureTree(); $theme_id = (int)$themes_helper->getCurrentThemeId(); - $root_category = $this->Application->getBaseCategory(); $this->_primaryLanguageId = $this->Application->GetDefaultLanguageId(); - $this->_structureTree = $this->_printChildren($data, $root_category, $this->Application->GetVar('m_lang'), $theme_id); + $this->_structureTree = $this->_printChildren($data, $data['id'], $this->Application->GetVar('m_lang'), $theme_id); return $this->_structureTree; } @@ -607,13 +627,16 @@ WHERE CategoryId IN (' . implode(',', $page_ids) . ')'; $templates = $this->Conn->GetCol($sql, 'CategoryId'); + $base_category = $this->Application->getBaseCategory(); + $templates[$base_category] .= '/Index'; // "Content" category will act as "Home Page" + foreach ($page_ids as $page_id) { - if (!array_key_exists($page_id, $templates)) { + if ( !isset($templates[$page_id]) ) { // internal page was deleted, but link to it was found in given content block data continue; } - $url_params = Array ('m_cat_id' => $page_id, 'pass' => 'm'); + $url_params = Array ('m_cat_id' => $page_id == $base_category ? 0 : $page_id, 'pass' => 'm'); $page_url = $this->Application->HREF(strtolower($templates[$page_id]), '', $url_params); /*if ($this->Application->isAdmin) { $page_url = preg_replace('/&(admin|editing_mode)=[\d]/', '', $page_url);