common.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* 验证码发送
* @param $mobile 手机号码
* @param $content 发送内容
* @param $type 验证码类型
*/
function send_sms($mobile,$content,$type=''){
}
/**
* 面包屑导航 用于前台用户中心
* 根据当前的控制器名称 和 action 方法
*/
function navigate_user()
{
$navigate = include APP_PATH.'home/navigate.php';
$location = strtolower('Home/'.CONTROLLER_NAME);
$arr = array(
'首页'=>'/',
$navigate[$location]['name']=>U('/Home/'.CONTROLLER_NAME),
$navigate[$location]['action'][ACTION_NAME]=>'javascript:void();',
);
return $arr;
}
/**
* 面包屑导航 用于前台商品
* @param type $id 商品id 或者是 商品分类id
* @param type $type 默认0是传递商品分类id id 也可以传递 商品id type则为1
*/
function navigate_goods($id,$type = 0)
{
$cat_id = $id; //
// 如果传递过来的是
if($type == 1){
$cat_id = M('goods')->where("goods_id", $id)->getField('cat_id');
}
$categoryList = M('GoodsCategory')->getField("id,name,parent_id");
// 第一个先装起来
$arr[$cat_id] = $categoryList[$cat_id]['name'];
while (true)
{
$cat_id = $categoryList[$cat_id]['parent_id'];
if($cat_id > 0)
$arr[$cat_id] = $categoryList[$cat_id]['name'];
else
break;
}
$arr = array_reverse($arr,true);
return $arr;
}