ecshop函数--assign_ur_here


http://www.topit.cn/ecshop-tutorial/ecshop_function_assign_ur_here-80.html


assign_ur_here

代码如下

  1. /**
  2.  * 取得当前位置和页面标题
  3.  *
  4.  * @access  public
  5.  * @param   integer     $cat    分类编号(只有商品及分类、文章及分类用到)
  6.  * @param   string      $str    商品名、文章标题或其他附加的内容(无链接)
  7.  * @return  array
  8.  */
  9. function assign_ur_here ( $cat = 0 , $str = '' )
  10. {
  11.     /* 判断是否重写,取得文件名 */
  12.     $cur_url = basename (PHP_SELF ) ;
  13.     if ( intval ( $GLOBALS [ '_CFG' ] [ 'rewrite' ] ) )
  14.     {
  15.         $filename = strpos ( $cur_url , '-' ) ? substr ( $cur_url , 0 , strpos ( $cur_url , '-' ) ) : substr ( $cur_url , 0 , - 4 ) ;
  16.     }
  17.     else
  18.     {
  19.         $filename = substr ( $cur_url , 0 , - 4 ) ;
  20.     }
  21.  
  22.     /* 初始化“页面标题”和“当前位置” */
  23.     $page_title = $GLOBALS [ '_CFG' ] [ 'shop_title' ] . ' - ' . 'Powered by ECShop' ;
  24.     $ur_here     = '<a href=".">' . $GLOBALS [ '_LANG' ] [ 'home' ] . '</a>' ;
  25.  
  26.     /* 根据文件名分别处理中间的部分 */
  27.     if ( $filename != 'index' )
  28.     {
  29.         /* 处理有分类的 */
  30.         if ( in_array ( $filename , array ( 'category' , 'goods' , 'article_cat' , 'article' , 'brand' ) ) )
  31.         {
  32.             /* 商品分类或商品 */
  33.             if ( 'category' == $filename || 'goods' == $filename || 'brand' == $filename )
  34.             {
  35.                 if ( $cat > 0 )
  36.                 {
  37.                     $cat_arr = get_parent_cats ( $cat ) ;
  38.  
  39.                     $key     = 'cid' ;
  40.                     $type     = 'category' ;
  41.                 }
  42.                 else
  43.                 {
  44.                     $cat_arr = array ( ) ;
  45.                 }
  46.             }
  47.             /* 文章分类或文章 */
  48.             elseif ( 'article_cat' == $filename || 'article' == $filename )
  49.             {
  50.                 if ( $cat > 0 )
  51.                 {
  52.                     $cat_arr = get_article_parent_cats ( $cat ) ;
  53.  
  54.                     $key   = 'acid' ;
  55.                     $type = 'article_cat' ;
  56.                 }
  57.                 else
  58.                 {
  59.                     $cat_arr = array ( ) ;
  60.                 }
  61.             }
  62.  
  63.             /* 循环分类 */
  64.             if ( ! empty ( $cat_arr ) )
  65.             {
  66.                 krsort ( $cat_arr ) ;
  67.                 foreach ( $cat_arr AS $val )
  68.                 {
  69.                     $page_title = htmlspecialchars ( $val [ 'cat_name' ] ) . '_' . $page_title ;
  70.                     $args       = array ( $key => $val [ 'cat_id' ] ) ;
  71.                     $ur_here   .= ' <code>&gt;</code> <a href="' . build_uri ( $type , $args , $val [ 'cat_name' ] ) . '">' .
  72.                                     htmlspecialchars ( $val [ 'cat_name' ] ) . '</a>' ;
  73.                 }
  74.             }
  75.         }
  76.         /* 处理无分类的 */
  77.         else
  78.         {
  79.             /* 团购 */
  80.             if ( 'group_buy' == $filename )
  81.             {
  82.                 $page_title = $GLOBALS [ '_LANG' ] [ 'group_buy_goods' ] . '_' . $page_title ;
  83.                 $args       = array ( 'gbid' => '0' ) ;
  84.                 $ur_here   .= ' <code>&gt;</code> <a href="group_buy.php">' .
  85.                                 $GLOBALS [ '_LANG' ] [ 'group_buy_goods' ] . '</a>' ;
  86.             }
  87.             /* 拍卖 */
  88.             elseif ( 'auction' == $filename )
  89.             {
  90.                 $page_title = $GLOBALS [ '_LANG' ] [ 'auction' ] . '_' . $page_title ;
  91.                 $args       = array ( 'auid' => '0' ) ;
  92.                 $ur_here   .= ' <code>&gt;</code> <a href="auction.php">' .
  93.                                 $GLOBALS [ '_LANG' ] [ 'auction' ] . '</a>' ;
  94.             }
  95.             /* 夺宝 */
  96.             elseif ( 'snatch' == $filename )
  97.             {
  98.                 $page_title = $GLOBALS [ '_LANG' ] [ 'snatch' ] . '_' . $page_title ;
  99.                 $args       = array ( 'id' => '0' ) ;
  100.                 $ur_here   .= ' <code> &gt; </code><a href="snatch.php">' .                                 $GLOBALS [ '_LANG' ] [ 'snatch_list' ] . '</a>' ;
  101.             }
  102.             /* 批发 */
  103.             elseif ( 'wholesale' == $filename )
  104.             {
  105.                 $page_title = $GLOBALS [ '_LANG' ] [ 'wholesale' ] . '_' . $page_title ;
  106.                 $args       = array ( 'wsid' => '0' ) ;
  107.                 $ur_here   .= ' <code>&gt;</code> <a href="wholesale.php">' .
  108.                                 $GLOBALS [ '_LANG' ] [ 'wholesale' ] . '</a>' ;
  109.             }
  110.             /* 积分兑换 */
  111.             elseif ( 'exchange' == $filename )
  112.             {
  113.                 $page_title = $GLOBALS [ '_LANG' ] [ 'exchange' ] . '_' . $page_title ;
  114.                 $args       = array ( 'wsid' => '0' ) ;
  115.                 $ur_here   .= ' <code>&gt;</code> <a href="exchange.php">' .
  116.                                 $GLOBALS [ '_LANG' ] [ 'exchange' ] . '</a>' ;
  117.             }
  118.             /* 其他的在这里补充 */
  119.         }
  120.     }
  121.  
  122.     /* 处理最后一部分 */
  123.     if ( ! empty ( $str ) )
  124.     {
  125.         $page_title   = $str . '_' . $page_title ;
  126.         $ur_here     .= ' <code>&gt;</code> ' . $str ;
  127.     }
  128.  
  129.     /* 返回值 */
  130.     return array ( 'title' => $page_title , 'ur_here' => $ur_here ) ;
  131. }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值