dede sql标签

dedecms

2010-04-24 14:53

这种比较常用!

   <ul>
        {dede:sql sql="SELECT id,title FROM `dede_archives` where ismake=1 order by id desc LIMIT 10"}
        <li>·<a href="[field:id function=URL(@me)'/]" target="_blank">[field:title/]</a></li>
        {/dede:sql}
   </ul>

然后写个URL函数放在include/common.func.php 或include/extend.func.php

function URL($id){
global $dsql;
if(!empty($id)){
    $row = $dsql->GetOne("select ar.* ,at.namerule,at.typedir,at.moresite,at.siteurl,at.sitepath from dede_archives as ar LEFT JOIN dede_arctype as at ON ar.typeid=at.id where ar.id={$id}");
}

return GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],
   $row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']);
}

比这种重复率高。
[field:aid runphp='yes']  
        @me = @me+1;
[/field:aid]