$res[$i]['category'], 'categoryid' => $res[$i]['categoryid'], 'subs' => makeArray($res[$i]['categoryid'], $res[$i]['category'], @$res[$i]['cdseo_url'], $cats[$cat_index], $level + 1), 'products' => getProducts($res[$i]['categoryid']), 'cdseo_url' => @$res[$i]['cdseo_url'] ); } $pages = array(); $res1 = func_query("SELECT pageid, title FROM $sql_tbl[pages] WHERE level = 'E' AND active = 'Y' AND language = '$store_language' ORDER BY orderby ASC"); for ($i = 0 ; $i < count($res1) ; $i++) { $pages[] = array( 'pageid' => $res1[$i]['pageid'], 'title' => $res1[$i]['title'] ); } function getProducts($id) { global $sql_tbl, $membershipid, $product_limit, $random_products, $cdseo_installed, $product_sort_field, $product_sort_dir; $ret = array(); if ($product_limit == 0) { return $ret; } else { $limit = ($product_limit != -1) ? "LIMIT 0, $product_limit" : ''; } if ($cdseo_installed) { $sql = " SELECT DISTINCT p.cdseo_url, p.productid, p.descr, p.product FROM $sql_tbl[products_categories] AS pc LEFT JOIN $sql_tbl[products] AS p ON pc.productid = p.productid AND pc.categoryid = $id LEFT JOIN $sql_tbl[product_memberships] AS pm ON pc.productid = pm.productid WHERE p.forsale = 'Y' AND (pm.membershipid = $membershipid OR pm.membershipid IS NULL) ORDER BY $product_sort_field $product_sort_dir $limit "; } else { $sql = " SELECT DISTINCT p.productid, p.descr, p.product FROM $sql_tbl[products_categories] AS pc LEFT JOIN $sql_tbl[products] AS p ON pc.productid = p.productid AND pc.categoryid = $id LEFT JOIN $sql_tbl[product_memberships] AS pm ON pc.productid = pm.productid WHERE p.forsale = 'Y' AND (pm.membershipid = $membershipid OR pm.membershipid IS NULL) ORDER BY $product_sort_field $product_sort_dir $limit "; } $res = func_query($sql); for ($i = 0 ; $i < count($res) ; $i++) { $ret[] = array( 'productid' => $res[$i]['productid'], 'product' => $res[$i]['product'], 'descr' => $res[$i]['descr'], 'cdseo_url' => @$res[$i]['cdseo_url'] ); } return $ret; } function makeArray($id, $name, $cdseo_url, $arr, $level) { global $max_level; if ($level > $max_level && $max_level > -1) { return $arr; } $index = 0; $subs = getSubs($id); for ($i = 0 ; $i < count($subs) ; $i++) { list($_name, $_id, $_cdseo_url) = explode('|', $subs[$i]); $arr[$index++] = array( 'name' => $_name, 'categoryid' => $_id, 'subs' => makeArray($_id, $_name, $_cdseo_url, $arr[$index]['subs'], $level + 1), 'products' => getProducts($_id), 'cdseo_url' => $_cdseo_url ); } return $arr; } $x = 0; function getSubs($id) { global $cdseo_installed, $category_sort_field, $category_sort_dir, $sql_tbl, $membershipid; if ($x++ >= 10) {exit();} $ret = array(); if ($cdseo_installed) { $sql = " SELECT c.cdseo_url, c.category, c.categoryid FROM $sql_tbl[categories] AS c LEFT JOIN $sql_tbl[category_memberships] AS cm ON cm.categoryid = c.categoryid WHERE c.parentid = '$id' AND c.avail = 'Y' AND (cm.membershipid = $membershipid OR cm.membershipid IS NULL) ORDER BY $category_sort_field $category_sort_dir "; } else { $sql = " SELECT c.category, c.categoryid FROM $sql_tbl[categories] AS c LEFT JOIN $sql_tbl[category_memberships] AS cm ON cm.categoryid = c.categoryid WHERE c.parentid = '$id' AND c.avail = 'Y' AND (cm.membershipid = $membershipid OR cm.membershipid IS NULL) ORDER BY $category_sort_field $category_sort_dir "; } $res = func_query($sql); if (count($res[0])) { for ($i = 0 ; $i < count($res) ; $i++) { $ret[] = $res[$i]['category'] . '|' . $res[$i]['categoryid'] . '|' . @$res[$i]['cdseo_url']; } } return $ret; } if (eregi('FTS Sitemap Cache', $HTTP_USER_AGENT)) { $config['Adaptives']['isJS'] = 'Y'; $smarty->assign('config', $config); } $location[] = array('Site Map', 'fts_sitemap.php'); $smarty->assign('cats', $cats); $smarty->assign('pages', $pages); $smarty->assign('main', 'fts_sitemap'); $smarty->assign('location', $location); func_display('customer/home.tpl', $smarty); ?>