Answer the question
In order to leave comments, you need to log in
Displaying subcategories in a tree-like way?
Please tell me how to display each category below Like
this:
Household appliances
-Built-in appliances
-Available
-Climatic equipment
-Custom order Created
categories and subcategories in the admin panel. I display with the {category-icon} tag. Now output joxi.ru/E2pXdQ7i98Dq12
The code itself
if( ! $row['category'] ) {
$my_cat = "---";
$my_cat_link = "---";
} else {
$my_cat = array ();
$my_cat_icon = array ();
$my_cat_link = array ();
$cat_list = explode( ',', $row['category'] );
if( count( $cat_list ) == 1 ) {
if( $allow_list[0] != "all" and ! in_array( $cat_list[0], $allow_list ) ) $perm = 0;
$my_cat[] = $cat_info[$cat_list[0]]['name'];
$my_cat_link = get_categories( $cat_list[0] );
if ($cat_info[$cat_list[0]]['icon']) {
$my_cat_icon[] = "<img src=\"{$cat_info[$cat_list[0]]['icon']}\" alt=\"{$cat_info[$cat_list[0]]['name']}\" />";
} else {
$my_cat_icon[] = "<img src=\"{THEME}/images/icons/{$cat_info[$cat_list[0]]['name']}.png\" alt=\"{$cat_info[$cat_list[0]]['name']}\" />";
}
} else {
foreach ( $cat_list as $element ) {
if( $allow_list[0] != "all" and ! in_array( $element, $allow_list ) ) $perm = 0;
if( $element ) {
$my_cat[] = $cat_info[$element]['name'];
if ($cat_info[$element]['icon']) {
$my_cat_icon[] = "<img src=\"{$cat_info[$element]['icon']}\" alt=\"{$cat_info[$element]['name']}\" />";
} else {
$my_cat_icon[] = "<img src=\"{THEME}/images/icons/{$cat_info[$cat_list[0]]['name']}.png\" alt=\"{$cat_info[$element]['name']}\" />";
}
if( $config['allow_alt_url'] == "yes" ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
}
}
$my_cat_link = implode( ', ', $my_cat_link );
}
$my_cat = implode( ', ', $my_cat );
$my_cat_icon = implode( '', $my_cat_icon);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question