Home > CMS Tutorial > DEDECMS > body text

How to use the Dreamweaver universal tag {dede:sql}

藏色散人
Release: 2019-11-16 09:52:12
Original
2952 people have browsed it

How to use the Dreamweaver universal tag {dede:sql}

How to use the Dreamweaver universal tag {dede:sql}?

Dreamweaver DEDECMS universal tag {dede:sql}

1. On the homepage, add a single-page document and content editing box in the background single-page document management Enter the content you want to generate.

2. Add the SQL universal tag {dede:sql sql="select body from dede_sgpage where aid=2"}[field:body /]{/dede:sql} where you need to call the single-page document I believe that friends who are familiar with SQL language can easily understand the meaning of this sentence.

The actual meaning is to select the body field input of the data table dede_sgpage. The 2 here in aid=2 means that you create a single-page document ID number. You can make corresponding modifications when using it.

Another example is this SQL tag sample code

{dede:sql sql="select content from dede_arctype where id=2"}
[field:content function=cn_substr(Html2Text(@me),600)/]
{/dede:sql}
Copy after login

Recommended study: dedecms tutorial

Based on the above example, it should be easy to understand, The main explanation here is that cn_substr means intercepting 600 characters, which is 300 Chinese characters. Html2Text means to filter out characters containing HTML and only display text.

In fact, in addition to the above examples, in the Dede system, I can freely use SQL statements to make more personalized calls with the DreamWeaver tag. Their 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"}
<li>·<a href="/plus/view.php?aid=[field:id/]">[field:title/]</a></li>
{/dede:sql}
Copy after login

You have seen that the underlying template address of the document link above is dynamic, so how do we 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=&#39;yes&#39;] $id=@me;@me=&#39;&#39;;$url=GetOneArchive($id);@me=$url[&#39;arcurl&#39;];[/field:id]" title="[field:title/]" target="_blank">[field:title function=cn_substr(@me,30,0)/]</a></li>
{/dede:sql}
Copy after login

The above is the detailed content of How to use the Dreamweaver universal tag {dede:sql}. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!