http://www.topit.cn/ecshop-tutorial/ecshop_function_assign_ur_here-80.html
assign_ur_here
代码如下
-
/**
-
* 取得当前位置和页面标题
-
*
-
* @access public
-
* @param integer $cat 分类编号(只有商品及分类、文章及分类用到)
-
* @param string $str 商品名、文章标题或其他附加的内容(无链接)
-
* @return array
-
*/
-
function assign_ur_here($cat = 0, $str = '')
-
{
-
/* 判断是否重写,取得文件名 */
-
$cur_url = basename(PHP_SELF);
-
if (intval($GLOBALS['_CFG']['rewrite']))
-
{
-
$filename = strpos($cur_url,'-') ? substr($cur_url, 0, strpos($cur_url,'-')) : substr($cur_url, 0, -4);
-
}
-
else
-
{
-
$filename = substr($cur_url, 0, -4);
-
}
-
-
/* 初始化“页面标题”和“当前位置” */
-
$page_title = $GLOBALS['_CFG']['shop_title'] . ' - ' . 'Powered by ECShop';
-
$ur_here = '<a href=".">' . $GLOBALS['_LANG']['home'] . '</a>';
-
-
/* 根据文件名分别处理中间的部分 */
-
if ($filename != 'index')
-
{
-
/* 处理有分类的 */
-
if (in_array($filename, array('category', 'goods', 'article_cat', 'article', 'brand')))
-
{
-
/* 商品分类或商品 */
-
if ('category' == $filename || 'goods' == $filename || 'brand' == $filename)
-
{
-
if ($cat > 0)
-
{
-
$cat_arr = get_parent_cats($cat);
-
-
$key = 'cid';
-
$type = 'category';
-
}
-
else
-
{
-
$cat_arr = array();
-
}
-
}
-
/* 文章分类或文章 */
-
elseif ('article_cat' == $filename || 'article' == $filename)
-
{
-
if ($cat > 0)
-
{
-
$cat_arr = get_article_parent_cats($cat);
-
-
$key = 'acid';
-
$type = 'article_cat';
-
}
-
else
-
{
-
$cat_arr = array();
-
}
-
}
-
-
/* 循环分类 */
-
if (!empty($cat_arr))
-
{
-
krsort($cat_arr);
-
foreach ($cat_arr AS $val)
-
{
-
$page_title = htmlspecialchars($val['cat_name']) . '_' . $page_title;
-
$args = array($key => $val['cat_id']);
-
$ur_here .= ' <code>></code> <a href="' . build_uri($type, $args, $val['cat_name']) . '">' .
-
htmlspecialchars($val['cat_name']) . '</a>';
-
}
-
}
-
}
-
/* 处理无分类的 */
-
else
-
{
-
/* 团购 */
-
if ('group_buy' == $filename)
-
{
-
$page_title = $GLOBALS['_LANG']['group_buy_goods'] . '_' . $page_title;
-
$args = array('gbid' => '0');
-
$ur_here .= ' <code>></code> <a href="group_buy.php">' .
-
$GLOBALS['_LANG']['group_buy_goods'] . '</a>';
-
}
-
/* 拍卖 */
-
elseif ('auction' == $filename)
-
{
-
$page_title = $GLOBALS['_LANG']['auction'] . '_' . $page_title;
-
$args = array('auid' => '0');
-
$ur_here .= ' <code>></code> <a href="auction.php">' .
-
$GLOBALS['_LANG']['auction'] . '</a>';
-
}
-
/* 夺宝 */
-
elseif ('snatch' == $filename)
-
{
-
$page_title = $GLOBALS['_LANG']['snatch'] . '_' . $page_title;
-
$args = array('id' => '0');
-
$ur_here .= ' <code> > </code><a href="snatch.php">' . $GLOBALS['_LANG']['snatch_list'] . '</a>';
-
}
-
/* 批发 */
-
elseif ('wholesale' == $filename)
-
{
-
$page_title = $GLOBALS['_LANG']['wholesale'] . '_' . $page_title;
-
$args = array('wsid' => '0');
-
$ur_here .= ' <code>></code> <a href="wholesale.php">' .
-
$GLOBALS['_LANG']['wholesale'] . '</a>';
-
}
-
/* 积分兑换 */
-
elseif ('exchange' == $filename)
-
{
-
$page_title = $GLOBALS['_LANG']['exchange'] . '_' . $page_title;
-
$args = array('wsid' => '0');
-
$ur_here .= ' <code>></code> <a href="exchange.php">' .
-
$GLOBALS['_LANG']['exchange'] . '</a>';
-
}
-
/* 其他的在这里补充 */
-
}
-
}
-
-
/* 处理最后一部分 */
-
if (!empty($str))
-
{
-
$page_title = $str . '_' . $page_title;
-
$ur_here .= ' <code>></code> ' . $str;
-
}
-
-
/* 返回值 */
-
return array('title' => $page_title, 'ur_here' => $ur_here);
-
}