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

dedecms uses sql statement to obtain article link address

王林
Release: 2021-02-04 10:33:33
forward
2442 people have browsed it

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}
Copy after login

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}
Copy after login

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}
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template