Home php教程 php手册 dedecms获取多级栏目

dedecms获取多级栏目

Jun 06, 2016 pm 07:35 PM
dedecms function Column Obtain

把函数getall放到include文件夹下的extend.func.php文件里面 DeDeCMS function getall($id){ global $dsql;$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid=$id order

把函数getall放到include文件夹下的extend.func.php文件里面
DeDeCMS

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

function getall($id){

    global $dsql;

    $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath FROM `dede_arctype` WHERE reid=$id order by sortrank asc";

    $dsql->SetQuery($sql);

    $dsql->Execute();

    while($row = $dsql->GetArray()) {

        $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row);

        $arrs[] = $row;

    }

    for($i=0;$i<count($arrs);$i++){

        $row2 = $dsql->GetOne("SELECT id FROM `dede_arctype` WHERE reid='$arrs[$i][id]'");

        if($row2['id'] > 0){

            $arrs[$i]['son'] = getall($arrs[$i]['id']);

        }

    }

    return $arrs;

}

Copy after login

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

//下面是模板代码,可自定义

{dede:php}

$res = getall(5);

$html = '';

for($i=0;$i<count($res);$i++){

    $html .="<li class='dm_on'><a onclick='dm_sidenav(\"mua".$res[$i][id]."\",this)' href='###' rurl='".$res[$i][typeurl]."'>".$res[$i][typename]."</a>";

        if(!empty($res[$i][son])){

            $lv2 = $res[$i][son];

            $html .="<ul id='mua".$res[$i][id]."'>";

            for($j=0;$j<count($lv2);$j++){

              $html .="<li><a onclick='dm_sidenav(\"muoa".$lv2[$j][id]."\",this)' rurl='".$lv2[$j][typeurl]."'>".$lv2[$j][typename]."</a>";

                  if(!empty($lv2[$j][son])){

                     $lv3 = $lv2[$j][son];

                     $html .="<ul id='muoa".$lv2[$j][id]."' style='display:none;'>";

                        for($u=0;$u<count($lv3);$u++){

                            $html .="<li><a href='".$lv3[$u][typeurl]."'>".$lv3[$u][typename]."</a> </li>";

                        }

                     $html .="</ul>";

                  }

             $html .="</li>";

            }

            $html .='</ul>';

         }

    $html .='</li>';

}

echo $html;

{/dede:php}

Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Tips for dynamically creating new functions in golang functions Tips for dynamically creating new functions in golang functions Apr 25, 2024 pm 02:39 PM

Tips for dynamically creating new functions in golang functions

Considerations for parameter order in C++ function naming Considerations for parameter order in C++ function naming Apr 24, 2024 pm 04:21 PM

Considerations for parameter order in C++ function naming

How to write efficient and maintainable functions in Java? How to write efficient and maintainable functions in Java? Apr 24, 2024 am 11:33 AM

How to write efficient and maintainable functions in Java?

Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Apr 21, 2024 am 10:21 AM

Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters

Complete collection of excel function formulas Complete collection of excel function formulas May 07, 2024 pm 12:04 PM

Complete collection of excel function formulas

What are the benefits of C++ functions returning reference types? What are the benefits of C++ functions returning reference types? Apr 20, 2024 pm 09:12 PM

What are the benefits of C++ functions returning reference types?

Advanced usage of reference parameters and pointer parameters in C++ functions Advanced usage of reference parameters and pointer parameters in C++ functions Apr 21, 2024 am 09:39 AM

Advanced usage of reference parameters and pointer parameters in C++ functions

What is the difference between custom PHP functions and predefined functions? What is the difference between custom PHP functions and predefined functions? Apr 22, 2024 pm 02:21 PM

What is the difference between custom PHP functions and predefined functions?

See all articles