SQL Command Line Tool -> Run SQL Command Line"; then add the sql code; finally use the dede tag to call That’s it."/> SQL Command Line Tool -> Run SQL Command Line"; then add the sql code; finally use the dede tag to call That’s it.">

Home >CMS Tutorial >DEDECMS >How to use sql statements to add custom attributes to the dedecms template in the backend of the dedecms website

How to use sql statements to add custom attributes to the dedecms template in the backend of the dedecms website

藏色散人
藏色散人Original
2019-12-18 09:30:412133browse

How to use sql statements to add custom attributes to the dedecms template in the backend of the dedecms website

How to use sql statements to add custom attributes to the dedecms template in the background of the dedecms website?

Dreamweaver dedecms template often feels that the attributes are not enough when calling articles in the frontend. We can customize many attribute tags, so that the frontend call can be very accurate, and adding is also very simple. The following is a solution I found online. Since it requires database operations, people who don’t understand should use it with caution. Otherwise, the consequences will be serious. If you delete the data table by mistake, you will say goodbye:

Recommended learning: woven Dreamcms

dedecmsHow to add the "custom attribute" label "symptom" in Dedecms

1. Enter the background - system - SQL command line tool ——Run the SQL command line and add the

code as follows:

“insert into `dede_arcatt`(sortid,att,attname) values(9,'d','症状');
alter table `dede_archives` modify `flag` set ('h','c','p','f','s','j','a','b','d') default NULL ”

The above SQL first inserts a new record (attribute to be added) into the table, and then modifies the flag field of another related table to add tag d. Yes, it's that simple, you have successfully added new attributes and can call the template. Of course, you can also use the phpmyadmin database tool to add attributes in a fool-proof way.

What needs to be explained is:

Line 1 of the code: values(9,'d','new custom attribute') is defined according to our needs, where 9 is the sortid The value is non-repeatable, that is, every time a custom attribute is added, the value of sortid should be incremented to 10, 11, 12..., and so on! d is the value of alt, which is the mark of the custom attribute, and it is the same as the existing one. The mark symbol cannot be repeated. "Symptom" is a Chinese name, which is convenient for people to intuitively understand the meaning of the custom attribute. It can be changed to other names as needed without affecting the call.

Line 2 of the code: set ('c','h','p','f','s','j','a','b','d'), The letters in brackets correspond to the existing mark symbols and the mark symbols you need to add, and they should be entered in order, and the order must not be changed. For example, d is ranked 9th, which corresponds to the custom attribute "Comment d" added in the first line of code.

2. Backend - Template - Default Template Management - index.htm

Make changes in the "index.htm" Dream Weaver template and add code where the symptoms need to be called

The code is as follows:

{dede:arclist flag=’d’ limit=’0,1′ infolen=’230′}

3. Add documents and add the code in the custom attribute This can be achieved by checking "New Custom Attributes". The checked document will appear in any place that needs to be called in the Dream Weaver template.

The above is the detailed content of How to use sql statements to add custom attributes to the dedecms template in the backend of the dedecms website. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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