function vam_show_category($counter)
{
    global $foo, $categories_string, $id;
    $categories_string .= '<li class="CatLevel' . $foo[$counter]['level'] . '';
    if ($id && in_array($counter, $id)) {
        $categories_string .= ' Current">';
    } else {
        $categories_string .= '">';
    }
    $categories_string .= '<a href="';
    $cPath_new = vam_category_link($counter, $foo[$counter]['name']);
    $categories_string .= vam_href_link(FILENAME_DEFAULT, $cPath_new);
    $categories_string .= '">';
    // display category name
    $categories_string .= $foo[$counter]['name'];
    if (SHOW_COUNTS == 'true') {
        $products_in_category = vam_count_products_in_category($counter);
        if ($products_in_category > 0) {
            $categories_string .= '&nbsp;(' . $products_in_category . ')';
        }
    }
    $categories_string .= '</a></li>';
    if ($foo[$counter]['next_id']) {
        vam_show_category($foo[$counter]['next_id']);
    } else {
        $categories_string .= '';
    }
}
function vam_show_top2level_category(&$list)
{
    global $categories_string;
    if (count($list) == 0) {
        return;
    }
    foreach ($list as $key => $item) {
        if (!isset($item['id'])) {
            continue;
        }
        $categories_string .= '<li class="CatLevel' . $item['level'] . '">';
        $categories_string .= '<a href=';
        $cPath_new = vam_category_link($item['id'], $item['name']);
        $categories_string .= vam_href_link(FILENAME_DEFAULT, $cPath_new);
        $categories_string .= '>';
        // display category name
        $categories_string .= $item['name'];
        if (SHOW_COUNTS == 'true') {
            $products_in_category = vam_count_products_in_category($item['id']);
            if ($products_in_category > 0) {
                $categories_string .= '&nbsp;(' . $products_in_category . ')';
            }
        }
        $categories_string .= '</a>';
        $chield_list = select_from_array($item['id']);
        if (count($chield_list) > 0) {
            vam_show_top2level_category($chield_list);
        }
        $categories_string .= '</li>';
    }
}
function vam_count_products_in_category($category_id, $include_inactive = false)
{
    $products_count = 0;
    if ($include_inactive == true) {
        $products_query = "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . $category_id . "'";
    } else {
        $products_query = "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . $category_id . "'";
    }
    $products_query = vamDBquery($products_query);
    $products = vam_db_fetch_array($products_query, true);
    $products_count += $products['total'];
    $child_categories_query = "select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . $category_id . "'";
    $child_categories_query = vamDBquery($child_categories_query);
    if (vam_db_num_rows($child_categories_query, true)) {
        while ($child_categories = vam_db_fetch_array($child_categories_query, true)) {
            $products_count += vam_count_products_in_category($child_categories['categories_id'], $include_inactive);
        }
    }
    return $products_count;
}
Ejemplo n.º 4
0
function vam_rss_category_tree($id_parent = 0, $cPath = '', $limit = null)
{
    global $db, $rss;
    if ($limit != null && $limit < 0) {
        return;
    }
    if ($limit != null) {
        $limit--;
    }
    $groups_cat_query = vam_db_query("select c.categories_id, c.parent_id, c.date_added, c.last_modified, c.categories_image, cd.categories_name, cd.categories_description\n\t\t\t\t\t\t\t\t\t\t\t from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd\n\t\t\t\t\t\t\t\t\t\t\t where c.parent_id = '" . (int) $id_parent . "'\n\t\t\t\t\t\t\t\t\t\t\t and c.categories_id = cd.categories_id\n\t\t\t\t\t\t\t\t\t\t\t and cd.language_id='" . (int) $_SESSION['languages_id'] . "'\n\t\t\t\t\t\t\t\t\t\t\t and c.categories_status= '1'\n\t\t\t\t\t\t\t\t\t\t\t order by c.sort_order, cd.categories_name");
    if (vam_db_num_rows($groups_cat_query) == 0) {
        return;
    }
    while ($groups_cat = vam_db_fetch_array($groups_cat_query)) {
        $link_categories = addslashes(vam_href_link(FILENAME_DEFAULT, vam_category_link($groups_cat['categories_id'], $groups_cat['categories_name']) . (isset($_GET['ref']) ? '&ref=' . $_GET['ref'] : null), 'NONSSL', false));
        $products_in_category = vam_count_products_in_category($groups_cat['categories_id']);
        if (CATEGORIES_COUNT_ZERO == '1' && $products_in_category == 0 or $products_in_category >= 1) {
            $rss->rss_feed_item($groups_cat['categories_name'], $link_categories, $link_categories, date('r', strtotime(max($groups_cat['date_added'], $groups_cat['last_modified']))), $groups_cat['categories_description'], $groups_cat['categories_image'], false, STORE_OWNER_EMAIL_ADDRESS . " (" . STORE_OWNER . ")");
        }
        if (vam_has_category_subcategories($groups_cat['categories_id'])) {
            vam_rss_category_tree($groups_cat['categories_id'], vam_not_null($cPath) ? $cPath . '_' . $groups_cat['categories_id'] : $groups_cat['categories_id'], $limit);
            // следующая группа
        }
        //		$groups_cat->MoveNext();
    }
}