eyoucms,获取当前栏目的父栏目id, getallpid方法
方法如下:
public function getAllPid($id, $is_RecycleBin = false)
{
$seo_pseudo = 0;
//查看多站点开关是否开启
$city_switch_on = config('city_switch_on');
if ($city_switch_on) {
$seo_pseudo = tpCache('seo.seo_pseudo');
}
//获取当前站点信息
$site = get_home_site();
$args = [THEME_STYLE, $id, $is_RecycleBin, $seo_pseudo, request()->baseFile(), $city_switch_on, $site];
$cacheKey = 'arctype-'.md5(__CLASS__.__FUNCTION__.json_encode($args));
$data = cache($cacheKey);
if (empty($data)) {
$data = array();
$typeid = $id;
$map = [
'status' => 1,
];
if (false === $is_RecycleBin) $map['is_del'] = 0;
$arctype_list = Db::name('Arctype')->field('*, id as typeid')
->where($map)
->getAllWithIndex('id');
if (isset($arctype_list[$typeid])) {
// 第一个先装起来
$arctype_list[$typeid]['typeurl'] = $this->getTypeUrl($arctype_list[$typeid]);
$data[$typeid] = $arctype_list[$typeid];
} else {
return $data;
}
while (true)
{
$typeid = $arctype_list[$typeid]['parent_id'];
if($typeid > 0 && $id != $typeid){
if (isset($arctype_list[$typeid])) {
$arctype_list[$typeid]['typeurl'] = $this->getTypeUrl($arctype_list[$typeid]);
$data[$typeid] = $arctype_list[$typeid];
}
} else {
break;
}
}
$data = array_reverse($data, true);
cache($cacheKey, $data, null, "arctype");
}
return $data;
}