function buildBranch($parent_id, $level = 0, $submenu = false)
 {
     if ($level == 0) {
         $result = $this->parent_group_start_string_noif;
     } else {
         $result = sprintf($this->parent_group_start_string, '');
     }
     if (isset($this->data[$parent_id])) {
         if ($this->i_display > 0) {
             $i = 0;
             while (list($category_id, $category) = each($this->data[$parent_id]) and $i <= $this->max_display) {
                 $category_link = $category_id;
                 if (isset($this->data[$category_id])) {
                     if ($b_top < 1 && $level == 1) {
                         $result .= sprintf($this->child_start_two, $submenu == true ? ' class="b_top"' : '');
                         $b_top++;
                     } else {
                         $result .= sprintf($this->child_start_two, '');
                     }
                 } else {
                     if ($b_top < 1 && $level == 1) {
                         $result .= sprintf($this->child_start_two, ' class="b_top"');
                         $b_top++;
                     } else {
                         $result .= sprintf($this->child_start_two, '');
                     }
                 }
                 if (isset($this->data[$category_id])) {
                     $result .= $this->parent_start_string;
                 }
                 if ($level == 0) {
                     $result .= $this->root_start_string;
                 }
                 if ($i == $this->max_display) {
                     $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . zen_get_categories_parent_id($category_link)) . '">';
                     $result .= 'All ' . zen_get_categories_parent_name($category_id);
                     $result .= '</a>';
                 } else {
                     $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '" title="' . SEO_COMMON_KEYWORDS . ' ' . $category['name'] . '">';
                     $result .= $category['name'];
                     if (zen_count_products_in_category($category_id)) {
                         $result .= '&nbsp;(' . zen_count_products_in_category($category_id) . ')';
                     }
                     $result .= '</a>';
                 }
                 if ($level == 0) {
                     $result .= $this->root_end_string;
                 }
                 if (isset($this->data[$category_id])) {
                     $result .= $this->parent_end_string;
                 }
                 if (isset($this->data[$category_id]) && ($this->max_level == '0' || $this->max_level > $level + 1)) {
                     $this->i_display++;
                     $result .= $this->buildBranch($category_id, $level + 1, $submenu);
                 }
                 $result .= $this->child_end_string;
                 $i++;
             }
         } else {
             while (list($category_id, $category) = each($this->data[$parent_id])) {
                 $category_link = $category_id;
                 if (isset($this->data[$category_id])) {
                     if ($b_top < 1 && $level == 1) {
                         $result .= sprintf($this->child_start_string, $submenu == true ? ' class="b_top"' : '');
                         $b_top++;
                     } else {
                         $result .= sprintf($this->child_start_string, '');
                     }
                 } else {
                     if ($b_top < 1 && $level == 1) {
                         $result .= sprintf($this->child_start_string, ' class="b_top"');
                         $b_top++;
                     } else {
                         $result .= sprintf($this->child_start_string, '');
                     }
                 }
                 if (isset($this->data[$category_id])) {
                     $result .= $this->parent_start_string;
                 }
                 if ($level == 0) {
                     $result .= $this->root_start_string;
                 }
                 $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '" title="' . SEO_COMMON_KEYWORDS . ' ' . $category['name'] . '">';
                 $result .= substr($category['name'], 0, 25);
                 if ($level == 0) {
                     if (zen_has_category_subcategories($category_id)) {
                         $result .= '<!--[if IE 7]><!--></a><!--<![endif]-->' . "\n";
                     } else {
                         $result .= '</a>' . "\n";
                     }
                     $result .= $this->root_end_string;
                 } else {
                     $result .= '</a>';
                 }
                 if (isset($this->data[$category_id])) {
                     $result .= $this->parent_end_string;
                 }
                 if (isset($this->data[$category_id]) && ($this->max_level == '0' || $this->max_level > $level + 1)) {
                     $this->i_display++;
                     $result .= $this->buildBranch($category_id, $level + 1, $submenu);
                 }
                 $result .= $this->child_end_string;
             }
         }
     }
     if ($level == 1) {
         $b_top = 0;
     }
     if ($level == 0) {
         $result .= $this->parent_group_end_string_noif;
     } else {
         $result .= $this->parent_group_end_string;
     }
     return $result;
 }
示例#2
0
<?php

$display_num = 12;
$subCategoriesArray = array();
if (isset($_GET['products_id'])) {
    $relatedCategoriesParentId = zen_get_products_category_id($_GET['products_id']);
    $relatedCategoriesId = zen_get_categories_parent_id($relatedCategoriesParentId);
    zen_get_subcategoriesarray($subCategoriesArray, $relatedCategoriesId);
} else {
    if (isset($current_category_id)) {
        $parent_id = zen_get_categories_parent_id($current_category_id);
        zen_get_subcategoriesarray($subCategoriesArray, $relatedCategoriesId);
    }
}
$relatedCategoriesTotalNum = count($subCategoriesArray);
?>
<div class="fl allborder line_180" id="relate_cate">
	<h4 class="red line_30px in_1em"><?php 
echo BASE_COMMON_TEXT_RELATEDCATEGORIES;
?>
</h4>
	<ul>
	<?php 
if ($relatedCategoriesTotalNum > 0) {
    for ($i = 0; $i < $display_num; $i++) {
        echo '<li><a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $subCategoriesArray[$i]['categories_id']) . '" title="' . SEO_COMMON_KEYWORDS . $subCategoriesArray[$i]['categories_name'] . '">' . zen_clipped_string($subCategoriesArray[$i]['categories_name']) . '</a></li>';
    }
}
unset($row, $display, $subCategoriesArray, $related_categories_query);
?>
	</ul>