dedecms导航栏目调用多种方法详解

  • 一一得一
  • 技术分享
  • Mar 30, 2022

1、基础调用

{dede:channel row='5' type ='top' currentstyle="<li class='hover'><a href='~typelink~' ~rel~><span>~typename~</span></a></li>"}
    <li><a href="[field:typelink/]">[field:typename/]</a></li>
{/dede:channel}

参数说明:

typeid = '0' 栏目ID
reid = '0' 上级栏目ID
row = '100' 调用栏目数
col = '1' 分多少列显示(默认为单列)
type = 'son' son表示下级栏目,self表示同级栏目,top顶级栏目
currentstyle = '' 应用样式

2、调用指定栏目

{dede:type typeid='1'}
    <li><a href="[field:typeurl/]">[field:typename/]</a></li> 
{/dede:type}

 

3、调用多个指定栏目

{dede:channelartlist row='2' typeid='1,2' }
    <li><a href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a></li>
{/dede:channelartlist}

4、调用多个指定栏目,并实现二级导航的调用

{dede:channelartlist row='2' typeid='11,2'}
          <li class="mainlevel">
            <a class="nav nav_02" href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a>
            <ul class="sv hide">
              {dede:channel type='son' noself='yes'}
              <li><a href="[field:typelink/]">[field:typename/]</a> </li>
              {/dede:channel}
            </ul>
          </li>
        {/dede:channelartlist}
 

 5、调用单个指定栏目,并实现二级导航的调用

 
{dede:channelartlist row='1' typeid='11,11'}
          <li class="mainlevel">
            <a class="nav nav_02" href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a>
            <ul class="sv hide">
              {dede:channel type='son' noself='yes'}
              <li><a href="[field:typelink/]">[field:typename/]</a> </li>
              {/dede:channel}
            </ul>
          </li>
        {/dede:channelartlist}
 

备注:typeid 后面的参数一定要添加两次,如果仅typeid='11',织梦后台将会调用子栏目

6、获取指定子栏目及子栏目文档

 
{dede:channelartlist  typeid='38'}
    <div><a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a></div>
    <ul>
        {dede:arclist titlelen='60' row='8'}
        <li>
            <img class="center-block" width="350" src="[field:picname/]">
            [field:title /]
        </li>
        {/dede:arclist}
    </ul>
{/dede:channelartlist}
 

 7、调取指定栏目下的文章

 
{dede:arclist  typeid='2' row='7' titlelen='100' }
   <li>
    <span>【[field:pubdate function="GetDateMK(@me)"/]】</span>
    <a href='[field:arcurl/]'>[field:title/]</a>
    <img src="[field:litpic/]" />
  </li>
{/dede:arclist}
 

 8、调取当前栏目链接与名称

{dede:type row=1}[field:typelink /]{/dede:type}


{dede:field.typename/}

 9、内容页调取所属栏目

{dede:type}
      <a href="[field:typelink/]">[field:typename/]</a>
{/dede:type}

 10、循环多个栏目下的文章

 
    {dede:channelArtlist typeid='1,2'}
   <div class="AList">
   {dede:type}
        <h3><a href="[field:typelink /]">>> [field:typename /]</a></h3>
   {/dede:type}
   <ul>
        {dede:arclist row="8" titlelen='100'}
            <li><span>[field:pubdate function="MyDate('Y/m/d',@me)"/]</span><a href="[field:arcurl /]" title="[field:title function='html2text(@me)'/]">[field:title function=' ( strlen("@me")>40 ? cn_substr("@me",40): "@me" ) '/]</a></li>
        {/dede:arclist}
   </ul>
   </div>
{/dede:channelArtlist}
 

 11、首页调取内容页调用栏目内容标签{dede:field.content/}

{dede:sql sql='Select content from dede_arctype where id=~typeid~'}
[field:content function='cn_substr(html2text(@me),800)'/]
{/dede:sql}

 12、判断是否有子栏目,有则显示否则隐藏(二级菜单调用)

 
{dede:channelartlist row=8 typeid='1,2,3,4,5'}
<li class="tab dropdown">
     <a href="{dede:field.typeurl/}" class="tablink arwlink" title="{dede:field.typename/}">{dede:field.typename/}</a>
     {dede:field name=typeid runphp="yes"}
     global $dsql; $sql = "SELECT id From `dede_arctype` WHERE reid='@me' And ishidden<>1 order by sortrank asc limit 0, 100 ";
     $row = $dsql->GetOne($sql);
     @me=is_array($row)?'<ul class="subnav">':'';
     {/dede:field}
 
     {dede:channel type='son' noself='yes' }
         <a href="[field:typeurl/]">[field:typename/]</a>
     {/dede:channel}
      
     {dede:field name=typeid runphp="yes"}
     global $dsql; $sql = "SELECT id From `dede_arctype` WHERE reid='@me' And ishidden<>1 order by sortrank asc limit 0, 100 ";
     $row = $dsql->GetOne($sql);
     @me=is_array($row)?'</ul>':'';
          {/dede:field}
</li>
{/dede:channelartlist}
 

 13列表页文章调用

 
{dede:list pagesize ='16'}
            <li class="item pull-left">
                <a class="item-wrap" href="[field:arcurl/]">
                    <div class="thumb">
                        <img src="[field:picname/]">
                    </div>
                    <p class="item-title">[field:title/]</p>
                </a>
            </li>
            {/dede:list}
 

 

打赏