Home  >  Article  >  CMS Tutorial  >  dedecms uses sql statement to obtain article link address

dedecms uses sql statement to obtain article link address

王林
王林forward
2021-02-04 10:33:332387browse

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=&#39;[field:id runphp=&#39;yes&#39;] $id=@me;@me=&#39;&#39;;$url=GetOneArchive($id);@me=$url[&#39;arcurl&#39;];[/field:id]&#39; 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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete