/**(V3.8 新增)(V6.9 更新) * 获取栏目的select * @param $name select的名称 * @param $value 选中的id,用于修改 * @param $root 顶级分类名称 * @param $member_publish 是否仅显示投稿栏目 * @param $attribute 外加属性 * @param $parent_disabled 是否禁父级栏目 * @param $disabled 是否禁单页和外部链接 * @param $modelid modelid * @return string */ function select_category($name='parentid', $value='0', $root='', $member_publish=0, $attribute='', $parent_disabled=true, $disabled=true, $modelid=0){ if($root == '') $root = '≡ 作为一级栏目 ≡'; $categorys = array(); $html='<select id="select" name="'.$name.'" class="select" '.$attribute.'>'; $html.='<option value="0">'.$root.'</option>'; $tree = yzm_base::load_sys_class('tree'); $data = D('category')->field('catid AS id,catname AS name,parentid,arrparentid,arrchildid,type,modelid,member_publish')->where(array('siteid'=>get_siteid()))->order('listorder ASC,catid ASC')->select(); $arrparentid = array(); if($modelid){ foreach($data as $catinfo){ if($catinfo['modelid']!=$modelid) continue; $key = md5($catinfo['arrparentid']); $arrparentid[$key] = isset($arrparentid[$key]) ? $arrparentid[$key].','.$catinfo['id'] : $catinfo['arrparentid'].','.$catinfo['id']; } $arrparentid = array_unique(explode(',', join(',', $arrparentid))); } $publish_arr = array(); if($member_publish){ foreach($data as $catinfo){ if($catinfo['member_publish']==0) continue; $key = md5($catinfo['arrparentid']); $publish_arr[$key] = isset($publish_arr[$key]) ? $publish_arr[$key].','.$catinfo['id'] : $catinfo['arrparentid'].','.$catinfo['id']; } $publish_arr = array_unique(explode(',', join(',', $publish_arr))); } foreach($data as $val){ if($modelid && !array_search($val['id'], $arrparentid)) continue; if($member_publish && !array_search($val['id'], $publish_arr)) continue; $val['html_disabled'] = 0; if($parent_disabled && strpos($val['arrchildid'], ',')) $val['html_disabled'] = 1; if($disabled && $val['type']) $val['html_disabled'] = 1; $categorys[$val['id']] = $val; } $tree->init($categorys); $tree->icon = array(' │ ',' ├─ ',' └─ '); $tree->nbsp = ' '; $html .= $tree->get_tree_category(0, "<option value='\$id' \$selected>\$spacer\$name</option>", "<optgroup label='\$spacer \$name'></optgroup>", $value); $html .= '</select>'; return $html; }
select_category
上一篇:adver
下一篇:get_category
有问题可以加入织梦技术QQ群一起交流学习
本站vip会员 请加入 VIP②群 PS:加入时备注用户名或昵称
普通注册会员或访客 请加入技术交流②群
作者:54818模板网 关注:633 时间:2023-05-16 16:39:07
相关网站教程: