在织梦DeDeCMS中,如何在 channel 标签里面调用栏目内容 content 标签,网上很多的织梦教程我看了一下,好像测试以后并没有调用出来。想让织梦栏目导航 channel 中支持调用栏目内容的新方法教程来了。
首先来说说 {dede:channelartlist ,因为他可以直接调用栏目内容,标签如下
{dede:channelartlist typeid='top' row='5' currentstyle="cur"} {dede:field.typeurl/} 栏目链接 {dede:field.typename/} 栏目名称 {dede:field.currentstyle/} 栏目高亮 {dede:field.content/} 栏目内容 {/dede:channelartlist}
SQL单独的调用 栏目内容也可以
{dede:sql sql="SELECT content FROM `#@__arctype` WHERE id=1"} [field:content/] 这种是直接调用栏目内容的,包含HTML [field:content function=cn_substr(html2text(@me),200)/] 这种是过滤HTML的截取200个字符 {/dede:sql}
使用 channelartlist 的话,可以直接使用,但是使用 channel 的就得改了。
{dede:channel type=top row='5'} [field:content/]不支持这种直接调用栏目内容 {/dede:channel}
如果想在 channel 中调用栏目内容 打开 /include/extend.func.php 中增加一个函数
//用typeid调用栏目内容 function content($typeid){ global $dsql; $sql=$dsql->getOne("select content from `#@__arctype` where id={$typeid}"); return $sql['content']; //return html2text($sql['content'],200); }
然后栏目调用标签
{dede:channel type=top row='5'} [field:typelink/] 栏目链接 [field:typename/] 栏目名称 [field:id function='content(@me)'/] 栏目内容 [field:id function='html2text(content(@me),200)'/] 栏目内容 这种是过滤HTML的截取200个字符 {/dede:channel}
嵌套的话就是这样
{dede:channelartlist typeid='top' row='5' currentstyle="cur"} {dede:field.typeurl/} 栏目链接 {dede:field.typename/} 栏目名称 {dede:field.currentstyle/} 栏目高亮 {dede:field.content/} 栏目内容 {dede:channel type=son noself=yes} [field:typelink/] 栏目链接 [field:typename/] 栏目名称 [field:id function='content(@me)'/] 栏目内容 [field:id function='html2text(content(@me),200)'/] 栏目内容 这种是过滤HTML的截取200个字符 {/dede:channel} {/dede:channelartlist}
完成。
+35 35 个回复 | 最后更新于 2025-01-16
登录后方可回帖