mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-07-08 22:40:43 +08:00
代码优化,去掉多余
This commit is contained in:
@ -33,12 +33,12 @@ class NavigationService
|
||||
// 缓存没数据则从数据库重新读取,顶部菜单
|
||||
if(empty($header))
|
||||
{
|
||||
$header = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>0))->order('sort')->select());
|
||||
$header = self::NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>0))->order('sort')->select());
|
||||
if(!empty($header))
|
||||
{
|
||||
foreach($header as $k=>$v)
|
||||
{
|
||||
$header[$k]['item'] = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>$v['id']))->order('sort')->select());
|
||||
$header[$k]['item'] = self::NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'is_show'=>1, 'pid'=>$v['id']))->order('sort')->select());
|
||||
}
|
||||
}
|
||||
S(C('cache_common_home_nav_header_key'), $header);
|
||||
@ -47,7 +47,7 @@ class NavigationService
|
||||
// 底部导航
|
||||
if(empty($footer))
|
||||
{
|
||||
$footer = NavDataDealWith($m->field($field)->where(array('nav_type'=>'footer', 'is_show'=>1))->order('sort')->select());
|
||||
$footer = self::NavDataDealWith($m->field($field)->where(array('nav_type'=>'footer', 'is_show'=>1))->order('sort')->select());
|
||||
S(C('cache_common_home_nav_footer_key'), $footer);
|
||||
}
|
||||
|
||||
@ -56,5 +56,44 @@ class NavigationService
|
||||
'footer' => $footer,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* [NavDataDealWith 导航数据处理]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2017-02-05T21:36:46+0800
|
||||
* @param [array] $data [需要处理的数据]
|
||||
* @return [array] [处理好的数据]
|
||||
*/
|
||||
public static function NavDataDealWith($data)
|
||||
{
|
||||
if(!empty($data) && is_array($data))
|
||||
{
|
||||
foreach($data as $k=>$v)
|
||||
{
|
||||
// url处理
|
||||
switch($v['data_type'])
|
||||
{
|
||||
// 文章分类
|
||||
case 'article':
|
||||
$v['url'] = HomeUrl('Article', 'Index', ['id'=>$v['value']]);
|
||||
break;
|
||||
|
||||
// 自定义页面
|
||||
case 'customview':
|
||||
$v['url'] = HomeUrl('CustomView', 'Index', ['id'=>$v['value']]);
|
||||
break;
|
||||
|
||||
// 商品分类
|
||||
case 'goods_category':
|
||||
$v['url'] = HomeUrl('Search', 'Index', ['category_id'=>$v['value']]);
|
||||
break;
|
||||
}
|
||||
$data[$k] = $v;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user