Home > Article > CMS Tutorial > dedecms uses sql statement to obtain article link address
Introduction:
In dedecms, you can use sql statements with dede tags to make personalized calls. The following will introduce to you how to use SQL statements to call the document list and obtain the page address.
The basic reference format is:
{dede:sql sql='select 字段 From 表名称 where 条件语句'} [field:字段名/] {/dede:sql}
From the above basic format, we can basically convert a call tag that calls the document list, the code is:
{dede:sql sql='select * From dede_archives limit 10'} <a href="../plus/view.php?aid=[field:id/]">[field:title/]</a> {/dede:sql}
The underlying template address of the above document link is dynamic, so how to convert it so that it can be linked to a static address? Here we only need to convert [field:id/]. The complete code after conversion is:
{dede:sql sql="SELECT * FROM dede_archives limit 10"} <li> <a href='[field:id runphp='yes'] $id=@me;@me='';$url=GetOneArchive($id);@me=$url['arcurl'];[/field:id]' title="[field:title/]" target="_blank">[field:title function=cn_substr(@me,30,0)/]</a> </li> {/dede:sql}
Related recommendations: 梦Weavercms
The above is the detailed content of dedecms uses sql statement to obtain article link address. For more information, please follow other related articles on the PHP Chinese website!