Блог в котором есть много интересной информации…
Ну, во первых, выясняем, что нам нужно разобраться со стилем sublevel:
идем где он находится с помощью команды
grep --color -r -i "sublevel" . --include=*.{php,css,html}
./administrator/components/com_virtuemart/classes/ps_product_category.php: $css_class = «sublevel«;
./administrator/components/com_virtuemart/classes/ps_product_category.php: $html .= «<a style=\»display:block;\» class=\»sublevel\» title=\»».$db->f(«category_name»).»\» href=\»»;
а если поискать только в css и htlm
grep --color -r -i "sublevel" . --include=*.{css,html}
то его нигде нет. Поэтому, наверное, его надо прописать. Добавляем sublevel в template.css, отступ слева делаем 24px:
.sublevel{
font-size:1.1em;
display:block;
background-position:3px 9px;
border-bottom:#cccc99 1px solid;
padding:4px 4px 4px 24px;
text-decoration:none;
}
теперь со стилями всё нормально, но VirtueMart добавляет nbsp:
открываем файл ./administrator/components/com_virtuemart/classes/ps_product_category.php и комментируем:
$html .= '<a title="'.$catname.'" style="display:block;'.$style.'" class="'. $css_class .'" href="'. $sess->url(URL."index.php?page=shop.browse&category_id=".$category_tmp[$row_list[$n]]["category_child_id"]) .'" '.$append.'>'
. /*str_repeat(" ",$depth_list[$n]) .*/ $catname
. ps_product_category::products_in_category( $category_tmp[$row_list[$n]]["category_child_id"] )
.'</a>';
Чтобы подкатегории показывались всегда, а не только тогда, когда активна родительская категория, в том же файле комментируем всё лишнее и добавляем “. $depth_list[$n]” в строке 726:
function get_category_tree( $category_id=0,
$links_css_class="mainlevel",
$list_css_class="mm123",
$highlighted_style="font-style:italic;" ) {
global $sess;
$categories = ps_product_category::getCategoryTreeArray(); // Get array of category objects
$result = ps_product_category::sortCategoryTreeArray($categories); // Sort array of category objects
$row_list = $result['row_list'];
$depth_list = $result['depth_list'];
$category_tmp = $result['category_tmp'];
$nrows = sizeof($category_tmp);
// Copy the Array into an Array with auto_incrementing Indexes
$key = array_keys($categories); // Array of category table primary keys
$nrows = $size = sizeOf($key); // Category count
$html = "";
//$html .= $category_id; -uncomment this line to show the active category id
//dmitriano commented this out to show all the subcategories
/*
// Find out if we have subcategories to display
$allowed_subcategories = Array();
if( !empty( $categories[$category_id]["category_parent_id"] ) ) {
// Find the Root Category of this category
$root = $categories[$category_id];
$allowed_subcategories[] = $categories[$category_id]["category_parent_id"];
// Loop through the Tree up to the root
while( !empty( $root["category_parent_id"] )) {
$allowed_subcategories[] = $categories[$root["category_child_id"]]["category_child_id"];
$root = $categories[$root["category_parent_id"]];
}
}
*/
// Fix the empty Array Fields
if( $nrows < count( $row_list ) ) {
$nrows = count( $row_list );
}
// Now show the categories
for($n = 0 ; $n < $nrows ; $n++) {
if( !isset( $row_list[$n] ) || !isset( $category_tmp[$row_list[$n]]["category_child_id"] ) )
continue;
if( $category_id == $category_tmp[$row_list[$n]]["category_child_id"] )
$style = $highlighted_style;
else
$style = "";
$allowed = true;
//dmitriano commented this out to show all the subcategories
/*
$allowed = false;
if( $depth_list[$n] > 0 ) {
// Subcategory!
if( isset( $root ) && in_array( $category_tmp[$row_list[$n]]["category_child_id"], $allowed_subcategories )
|| $category_tmp[$row_list[$n]]["category_parent_id"] == $category_id
|| $category_tmp[$row_list[$n]]["category_parent_id"] == @$categories[$category_id]["category_parent_id"]) {
$allowed = true;
}
}
else
$allowed = true;*/
$append = "";
if( $allowed ) {
if( $style == $highlighted_style ) {
$append = 'id="active_menu"';
}
if( $depth_list[$n] > 0 ) {
$css_class = "sublevel" . $depth_list[$n];
}
else {
$css_class = $links_css_class;
}
$catname = shopMakeHtmlSafe( $category_tmp[$row_list[$n]]["category_name"] );
$html .= '
<a title="'.$catname.'" style="display:block;'.$style.'" class="'. $css_class .'" href="'. $sess->url(URL."index.php?page=shop.browse&category_id=".$category_tmp[$row_list[$n]]["category_child_id"]) .'" '.$append.'>'
. /*str_repeat(" ",$depth_list[$n]) .*/ $catname
. ps_product_category::products_in_category( $category_tmp[$row_list[$n]]["category_child_id"] )
.'</a>';
}
}
return $html;
}
соответственно в css теперь будет отдельный стиль для каждого уровня подкатегорий:
.sublevel1{
font-size:1.1em;
display:block;
background-position:3px 9px;
border-bottom:#cccc99 1px solid;
padding:4px 4px 4px 24px;
text-decoration:none;
}
.sublevel2{
font-size:1.1em;
display:block;
background-position:3px 9px;
border-bottom:#cccc99 1px solid;
padding:4px 4px 4px 32px;
text-decoration:none;
}