不多说,直接贴代码:
数据源调用方法就不多说了,在有关phpcms数据源调用中有详细的介绍
实现原理:添加一个过滤函数
<?php
function clearHtml($content)
{
$content=preg_replace('/\[[^\[\]]{1,}\]/','',$content);
return $content;
}
?>
{get dbsource="bbs" sql="SELECT a.tid,a.subject, b.attachment,c.message FROM `cdb_threads` a, `cdb_attachments` b,`cdb_posts` c WHERE a.tid = b.tid and a.tid=c.tid AND a.fid=21and a.typeid=101 GROUP BY b.tid ORDER BY a.dateline DESC LIMIT 0,3"}
<a href="bbs/viewthread.php?tid={$r[tid]}" target="_blank">·{str_cut($r[subject], 26,'')}</a>
<a href="bbs/viewthread.php?tid={$r[tid]}" target="_blank"><img src="bbs/attachments/{$r[attachment]}" width=100></a>
{str_cut(clearhtml($r[message]),50,'')}
{/get}
直接在phpcms 相应的模板中修改即可。
原文来自:http://www.mianfeimoban.com/phpcms_jc/1362.html