利用SQL来实现,以下是我的源码,要根据你的数据库表名自行改动:
{dede:sql sql="select as_ask.id,as_ask.title,as_askanswer.content from as_ask LEFT JOIN as_askanswer on as_ask.id=as_askanswer.askid where as_askanswer.ifanswer=1 and as_askanswer.ifcheck=1 or as_ask.bestanswer=as_askanswer.id order by as_ask.id desc LIMIT 0,1"}<br /><strong>问:</srtong><a href="/ask/question.php?id=[field:id/]" class="link3">[field:title function=cn_substr(@me,46)/]</a><br /><p><strong>答:</srtong>[field:content function=cn_substr(html2text(@me),40)/],...<a href="/ask/question.php?id=[field:id/]" class="link2">详情>></a></p><br />{/dede:sql}
放在首页任意位置调用就可以了。
里面调用条数,长度,可以根据自己的需求进行调整 。
可在在全局标记测试效果。
如果需要分栏目调用,那么加入as_ask.tid2=XX,如我的整形栏目为as_ask.tid2=7,调用如下:
{dede:sql sql="select as_ask.id,as_ask.title,as_askanswer.content from as_ask LEFT JOIN as_askanswer on as_ask.id=as_askanswer.askid and as_ask.tid2=7 where as_askanswer.ifanswer=1 and as_askanswer.ifcheck=1 or as_ask.bestanswer=as_askanswer.id order by as_ask.id desc LIMIT 0,1"}<br /><strong>问:</srtong><a href="/ask/question.php?id=[field:id/]" class="link3">[field:title function=cn_substr(@me,46)/]</a><br /><p><strong>答:</srtong>[field:content function=cn_substr(html2text(@me),40)/],...<a href="/ask/question.php?id=[field:id/]" class="link2">详情>></a></p><br />{/dede:sql}

免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。