dedecms如何在列表页调出文章内容【body字段】

来源:互联网 发布:ar2220 s网络配置实例 编辑:程序博客网 时间:2024/06/05 22:36

我们可以用截取文章前100个字作为文章简介,这里要组合使用用两个函数cn_substr和html2text,对文章转义后截取。测试代码:[field:body function="cn_substr(html2text(@me),200)"/],结果发现还是不行,因为body和description不在同一张表里。所以只好从程序上入手了。

打开include文件下extend.func.php添加以下代码:

function GetOneArchiveBody($aid,$length){global $dsql;$aid = trim(ereg_replace('[^0-9]','',$aid));$body = '';$query = " Select art.body From `#@__addonarticle` art, `#@__archives` arc where art.aid='$aid' and art.aid=arc.id ";$arcRow = $dsql->GetOne($query);if(!is_array($arcRow)) {return $body;}if(isset($arcRow['body'])) {$body = cn_substr(html2text($arcRow['body']),$length);}return $body;}


在前台模板调用:

{dede:list pagesize='10'}

[field:title/]

[field:id function="GetOneArchiveBody(@me,200)"/]...

作者:[field:writer/]

发表于:[field:pubdate function="GetDateTimeMK(@me)"/] 评论:[field:scores/] 点击:[field:click/]

{/dede:list}


如果你想调用单一文章 栏目id是2 文章id是2

{dede:arclist typeid="2" idlist="2"}

[field:id function="GetOneArchiveBody(@me,700)"/]...

{/dede:arclist}

0 0
原创粉丝点击