Skip to main content
 Web开发网 » 站长学院 » 织梦教程

怎么在首页调用dede子栏目

2020年09月12日8310百度已收录

{dede:channelartlist typeid='栏目ID' row='条数'}

<div class="list">

<li><a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a></li>

<ul>

{dede:sql sql='Select * from dede_arctype where reid=~id~ ORDER BY id limit 0,7'}

<li><a href='[field:typedir/]' target='_blank'>[field:typename/]</a></li>

{/dede:sql}

</ul>

</div>

{/dede:channelartlist}

代码功能:父栏目及子栏目同时调用

使用说明……typeid,row

如果[field:typedir/]中含有{cmspath}而使链接无效,请使用[field:typedir function='str_replace("{cmspath}","",@me)'/] 此标签替换[field:typedir/]。

{dede:field name='typedir' runphp='yes'}

@me=str_replace("{cmspath}","",@me);

{/dede:field}

一、二、三级栏目调用

{dede:channelartlist typeid=top row=4}

<div class="cpmll">

<span><a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a></span>

<ul>

{dede:sql sql='Select * from dede_arctype where reid=~id~ ORDER BY id limit 0,7'}

<li><a href='[field:typedir/]' target='_blank'>[field:typename/]</a></li>

{/dede:sql}

</ul>

</div>

{/dede:channelartlist}

主栏目调用

{dede:channelartlist typeid=top row=''}

<li><a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a>

<ul>

{dede:sql sql='Select * from dede_arctype where reid=~id~ ORDER BY id limit 0,7'}

[field:array runphp='yes']@me = (!empty(@me['reid']) ? "" : "<li><a href='{@me['typedir']}' target='_blank'>{@me['typename']}</a></li>"); [/field:array]

{/dede:sql}

</ul>

</li>

{/dede:channelartlist}

在列表页和内容页调用顶级栏目名称方法

{dede:field.typeid runphp='yes' function="GetTopid(@me)"}

$dsql = new DedeSql(false);

$a="SELECT typename FROM dedemuban_arctype where id=@me";

$arcRow = $dsql->GetOne($a);

@me=$arcRow[typename];{/dede:field.typeid}

根据下级栏目获得顶级栏目名称的SQL语句

{dede:field.typeid runphp='yes'}$ID = @me; $sql = "SELECT * FROM `dede_arctype` WHERE id=$ID";$query = mysql_query($sql);$row=mysql_fetch_array($query); $relID = "$row[reid]"; if($relID == 0) {@me = $row[typename];}else{$sql = "SELECT `typename` FROM `dede_arctype` WHERE id=$relID";$query = mysql_query($sql);$row=mysql_fetch_array($query); @me = $row[typename];}{/dede:field.typeid}

怎么在首页调用dede子栏目

{dede:channel type='son' typeid='栏目ID'}

<a href="[field:typelink/]">[field:typename/]</a>

{/dede:channel}

------------------------------

例如同时调用顶级栏目,全站文章和顶级栏目下的子栏目:

{dede:channel type='top' row='800'}

<a href='[field:typelink/]'>[field:typename/]</a>,1<br />

{/dede:channel}

--------------------------------------------------<br />

{dede:arclist row='80000' titlelen='40' orderby='pubdate' idlist=''}

[field:textlink/],1<br/>

{/dede:arclist}

--------------------------------------------------<br />

{dede:channelartlist row='3000'}

<a href="{dede:field name='typeurl'/}">{dede:field name='typename'/}</a><br />

<ul>

{dede:sql sql='Select * from dede_arctype where reid=~id~ ORDER BY id limit 0,3000'}

<a href='[field:typedir/]' target='_blank'>[field:typename/]</a>,1<br />

{/dede:sql}

</ul>

{/dede:channelartlist}


 

评论列表暂无评论
发表评论
微信