/**
* get the SEF Category name for $catname
* called from: create_sefurl
**/
function getCategoryName($catname, $isChild = false)
{
    global $PortaMxSEF;
    getCategoryNameList();
    $tmp = array_flip($PortaMxSEF['CatNameList']['name']);
    if (!empty($tmp[$catname])) {
        return (empty($isChild) ? 'category/' : '') . $tmp[$catname] . '/';
    } else {
        return 'pmxerror/category/';
    }
}
Example #2
0
/**
 * 獲取分類名稱列表
 */
function getCategoryNameList($tab, $tab_id)
{
    if (empty($tab) || empty($tab_id)) {
        return false;
    }
    global $webdb;
    $list = $webdb->getList("select c.parent_id,c.name from " . $tab . " as c where c.id=" . $tab_id);
    $result = array();
    if (!empty($list)) {
        foreach ($list as $rs) {
            if ($rs['parent_id'] > 0) {
                $result[] = getCategoryNameList($tab, $rs['parent_id']);
            }
            //開始遞迴
            $result[] = $rs['name'];
        }
        unset($rs, $list);
    }
    return implode(" / ", $result);
}