eyoucms开发之快速函数(根据当前id和字段,或者同父栏目的上一个栏目或者下一个栏目信息)

这个函数用处不大,但是用到时,比较好用。所以分享给大家,

代码如下:


//根据栏目id或者上一个栏目信息

if(!function_exists('diy_get_pre_type')){

function diy_get_pre_type($id = '', $field = '', $admin_lang = 'cn')

{

if($admin_lang == 'cn'){

$pid = 285;

}elseif($admin_lang == 'en'){

$pid = 286;

}

$arctype_where = [

'is_hidden'=>0,

'admin_id'=>1,

'parent_id'=>$pid,

'lang'=>$admin_lang

];

$arctype_data = M('arctype')->where($arctype_where)->where('id','<',$id)->order('id desc')->find();

$data = $arctype_data[$field];

return $data;

}

}

//根据栏目id获取下一个栏目信息

if(!function_exists('diy_get_next_type')){

function diy_get_next_type($id = '',$field = '', $admin_lang = 'cn')

{

if($admin_lang == 'cn'){

$pid = 285;

}elseif($admin_lang == 'en'){

$pid = 286;

}

$arctype_where = [

'is_hidden'=>0,

'admin_id'=>1,

'parent_id'=>$pid,

'lang'=>$admin_lang

];

$arctype_data = M('arctype')->where($arctype_where)->where('id','>',$id)->order('id asc')->find();

$data = $arctype_data[$field];

return $data;

}

}




联系我们

在线咨询:点击这里给我发消息

邮件:w420220301@qq.com