thinkphp无限分类应用,仿织梦栏目管理

最近官网上关于无限分类的分享很多,大象也来分享一下我的无限分类,是看了织梦的栏目管理后得写出来的,优点是管理方便,多层级,为此我还写了jquery进行关闭展开分类,缺点是不可重用,希望高手们能给出见解,变成一个可重用的,不过我觉得栏目管理这东西,一个站最多一个,所以重用意义也不大。大象QQ:576272452

织梦的栏目管理非常帅,多级栏目显示上面非常清晰,今天大象仿了个织梦的多级栏目管理,废话不多说,上代码

1、递归类 Typeunit.calss.php

<?

class Typeunit {

    /**

     *  读出所有分类,在类目管理页(list_type)中使用

     *

     * @access    public

     * @param     int   $table  表名

     * @param     int   $topid  当前操作ID

     * @return    string

     */

     public function ListType($table='keshi',$topid=0){

        $Form = M($table);

        $list = $Form->where('topid='.$topid)->order("sort desc,id asc")->select();

        foreach ($list as $k => $v) {

             echo '<tr align="center"  bgcolor="#FBFCE2" height="22" class="fid"><td width="7%"><span class="jia"></span>ID</td><td width="14%">'.$v['id'].'</td><td width="14%">'.$v['name'].'</td><td>操作</td></tr>';

             $this->ListTypeSeed($table,$v['id']);

         } 

    }

       

    /**

     *  读出子分类

     *

     * @access    public

     * @param     int   $table  表名

     * @param     int   $topid  当前操作ID

     * @return    string

     */

    private function ListTypeSeed($table,$topid){

        $Form = M($table);

        $list = $Form->where('topid='.$topid)->order("sort desc,id asc")->select();

        if($list){

            echo '<tr align="center"  bgcolor="#FFFFFF" height="22" class="seed"><td colspan="4"><table width="98%">';

            foreach ($list as $k => $v) {

                 echo '<tr align="center" bgcolor="#FAFAF1" height="22"><td width="7%"><span class="jia"></span>ID</td><td width="14%">'.$v['id'].'</td><td width="14%">'.$v['name'].'</td><td>操作</td></tr>';

                 $this->ListTypeSeed("keshi",$v['id']);

             }

            echo '</table></td></tr>';

        }

    }

}

?>

2、模板页面 index.html

<script>

$(function(){

    /*

    * 点击展开子类

    *

    */

    $(".jia").click(function(){

        if($(this).parent("td").parent("tr").next(".seed").is(":hidden")){

            $(this).parent("td").parent("tr").next(".seed").show();

            $(this).html("-");

        }else{

            $(this).parent("td").parent("tr").next(".seed").hide();

            $(this).html("+");  

        }

          

    });

    //初始化全部都是-号

    $(".seed").prev(".fid").find("td").find("span.jia").html("-");

      

    /*

    * 点击关闭所有子类

    *

    */

    $("#closeseed").click(function(){

        if($(this).val() == "展开所有子类"){

            $(".seed").show();

            $(this).val("关闭所有子类");

            $.each($(".jia"),function(k,v){

                if($(this).html()){

                    $(this).html("-");

                }

            });                     

        }else{

            $(".seed").hide();

            $(this).val("展开所有子类");

            $.each($(".jia"),v){

                if($(this).html()){

                    $(this).html("+");

                }

            });     

        }       

    });

});

</script>

<php>

    $tu = new Typeunit();

    $tu->ListType('keshi',0);

</php>

相关文章

(1)创建数据表: CREATE TABLE IF NOT EXISTS `think_form` ...
组合查询的主体还是采用数组方式查询,只是加入了一些特殊的...
(1)创建模版:/App/Home/View/Form/edit.html   <FORM m...
自定义配置文件user.php: <?php return array(    \'se...
在一些成熟的CMS系统中,后台一般都包含一个配置中心(如织梦...
废话不多说先上图预览下,即本博客的分页; 这个分页类是在...