Home
Idents in categories Print
Written by Roman   

This article is regarding how the virtuemart displayscategories, if acategory is quite long.
I used version 1.0.6 of virtuemart. You need to change file ps_product_category.php. It's placed in: administrator\components\com_virtuemart\classes
Find the function get_category_tree:

function get_category_tree( $category_id=0,
$links_css_class="mainlevel",
$list_css_class="mm123",
$highlighted_style="font-style:italic;" ) {
global $sess;
$margin_left;
$categories = ps_product_category::getCategoryTreeArray();
...
$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&amp;category_id="
.$category_tmp[$row_list[$n]]["category_child_id"])
.'" '.$append.'>'.str_repeat("&nbsp;&nbsp;&nbsp;",$depth_list[$n])
. $catname. ps_product_category::products_in_category(
$category_tmp[$row_list[$n]]["category_child_id"] )
.'</a>';
} }

&nbsp;&nbsp;&nbsp; - these word spaces are used to pick out categories.

So, if the name of a category is long it's displayed as a line folding with spaces in the begging of the category. Like this:

Let's make categories tree more readable:

$catname = shopMakeHtmlSafe(
$category_tmp[$row_list[$n]]["category_name"] );
$margin_left=$depth_list[$n]*10;
 /*this will be the indents for a category. We use the
variable $margin_left to put value of the indent of sub-category into
the html code. Each sub-category will be displaced by the 10px amount
relative to it’s parent category.*/
$html .= '
<a title="'.$catname.'" style="display:block;margin-left:'.$margin_left.
'px;'.$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
.$catname.ps_product_category::products_in_category(
$category_tmp[$row_list[$n]]["category_child_id"] )
.'</a>';

Here will be the indents for a category. We use variable $margin_left to put value of the indent of sub-category into the html out-put.

Each sub-category will be displaced by the 10px amount relative to it's parent category. As you can see, we commented out string with spaces: "&nbsp;&nbsp;&nbsp;", it's no more needed.

This is how category looks after changing:

download file ps_product.php in zip. (Don't forget to make back-up)

» No Comments
There are no comments up to now.
» Post Comment
Email (will not be published)
Name
Title
Comment
 remaining characters
Captcha Image Regenerate code when it's unreadable