muban大师 发表于 2021-5-18 10:06:03

织梦怎么调用顶级栏目以及下面的二级栏目

织梦调用顶级栏目以及下面的二级栏目
       
        有些时候需要调用顶级栏目以及下面的二级栏目,例如再做下拉菜单时。最简单的调用二级栏目的办法:
       
       
               
                       
                               
                                       
{dede:channelartlist typeid='top'}
[*,

{dede:channel type='son' noself='yes'}
[*,
{/dede:channel}


{/dede:channelartlist}
                               
                       
               
       
有些时候需要做样式时,需要为dede:channelartlist 里的某个标签加上不同的css,例如下面的例子:


       
               
                       
                               
{dede:channelartlist typeid='top'}
[*,

{dede:channel type='son' noself='yes'}
[*,
{/dede:channel}


{/dede:channelartlist}
                       
               
       


        {dede:global name=’itemindex’/}为在每次调用顶级栏目,自动递增。
       
        更复杂的调用二级栏目的方式,要用dede:php标签,如下例:
       
       
               
                       
                               
                                       

[*,
{dede:channelartlist typeid='top'}
{dede:php}
$thisid = $refObj->Fields['id',;
$dsql->SetQuery("Select * from `dede_arctype` where reid=".$thisid." ORDER BY sortrank");
$dsql->Execute();
$i=0;
while($arr = $dsql->getArray()){
$i = $i +1;
$str = implode(',',$arr);
if(!empty($str) && $i==1){
echo '[*,

';
}
echo '';
}
if(!empty($str)) echo '';
if(empty($str)){
echo '[*,';
}
{/dede:php}


{/dede:channelartlist}

                               
                       
               
       
这种方式虽然更复杂,但也更灵活。
页: [1]
查看完整版本: 织梦怎么调用顶级栏目以及下面的二级栏目