dedecms可以在模板直接調用同數(shù)據(jù)庫里其他數(shù)據(jù)表的數(shù)據(jù),有兩種常用的方法,
1,用loop標簽,比如論壇的新帖,調取的格式是
{dede:loop:table="表名" if="條件" sort="倒序排序的字段名" row="條數(shù)"}
{/dede:loop}
例如調用論壇最新主題
{dede:loop table="cdb_threads" if="fid=5 and displayorder!=-1" sort="views" row="10"}
<a href="/dz/viewthread.php?tid=[field:tid /]">
·[field:subject function="cn_substr('@me',30)" /]([field:lastpost function="date('m-d H:M','@me')" /])
</a>
{/dede:loop}
2,用sql標簽
{dede:sql sql="Select id as post_id,post_title as post_title,post_type,post_date from wp_posts where post_type = 'post' order by post_date desc limit 1,10″}
<a href='http://www.ni9ht.com/blog/[field:post_id /].html'>[field:post_title /]</a>
{/dede:sql}