• 无限分类方法大全


    1)

    视图:

    <select name="command">
    <option>选择操作</option>
    <?php foreach ((array)$datalist as $row):?>
    <option><?php echo $row['str_repeat'].$row['catalog_name_alias'] ?></option>
    <?php endforeach;?>
    </select>

    2.控制器里面去取$datalist:

    $datalist = Catalog::get(0, $this->_catalog);(父id为0的,说明是所有)

    3.catalog模型里面的函数:

        /**
         * 取分类
         */
    	static public function get($parentid = 0, $array = array(), $level = 0, $add = 2, $repeat = '-') {
            
            $str_repeat = '';
            if ($level) {
                for($j = 0; $j < $level; $j ++) {
                    $str_repeat .= $repeat;
                }
            }
            $newarray = array ();
            $temparray = array ();
            foreach ( ( array ) $array as $v ) {
                if ($v ['parent_id'] == $parentid) {
                    $newarray [] = array ('id' => $v ['id'], 'catalog_name' => $v ['catalog_name'],
    				'catalog_name_alias' => $v ['catalog_name_alias'],
    				'parent_id' => $v ['parent_id'], 'level' => $level, 'sort_order' => $v ['sort_order'], 
    				'seo_keywords' => $v ['seo_keywords'], 'seo_description' => $v ['seo_description'], 
    				'attach_file' => $v ['attach_file'], 'attach_thumb' => $v ['attach_thumb'], 
    				'status_is' => $v ['status_is'], 'data_count' => $v ['data_count'] , 
    				'display_type' => $v ['display_type'], 'menu_is' => $v ['menu_is'],
    				'template_list' => $v ['template_list'],'acl_browser' => $v ['acl_browser'],
    				'acl_operate' => $v ['acl_operate'],'template_page' => $v ['template_page'],
    				'template_show' => $v ['template_show'],'create_time' => $v ['create_time'],
    				'str_repeat' => $str_repeat, 'page_size'=>$v['page_size'] );
        
                    $temparray = self::get ( $v ['id'], $array, ($level + $add) );
                    if ($temparray) {
                        $newarray = array_merge ( $newarray, $temparray );
                    }
                }
            }
            return $newarray;
        }
    

      

  • 相关阅读:
    -Dmaven.test.skip=true 和 -DskipTests
    mysql 生成指定范围随机数
    Delphi 6 保存窗体设置
    Sql server left join,right join和inner join的比较
    Mysql配置文件my.ini详解
    网络游戏MMORPG服务器架构
    彻底删除SVN版本库中部分文件或文件夹
    高负载高并发应用 参考索引 地址
    Linux计划任务入门详解
    Linux下SVN的三种备份方式
  • 原文地址:https://www.cnblogs.com/fengzhiqiangcaisangzi/p/3363813.html
Copyright © 2020-2023  润新知