dede field name是什么标签?

99ANYc3cd6
预计阅读时长 19 分钟
位置: 首页 DEDE建站 正文

Of course! The dede_field name is a core concept in the DedeCMS (织梦内容管理系统) database. It's the central table that stores the custom fields for your website's content.

dede field name
(图片来源网络,侵删)

Let's break it down in detail.


What is dede_field?

In simple terms, dede_field is a lookup table that defines all the extra, user-defined fields you can add to a specific content model (also called an "arctype" or channel).

Think of it this way:

  • dede_archives: This table holds the standard, fixed information for every article, like its title, author, publishing date, and the main body content.
  • dede_field: This table holds the definitions for additional information you might want to capture. For example, if you're running a product review site, you could add custom fields like "Product Rating," "Price," or "Release Date." The dede_field table stores the names and properties of these custom fields.

Every time you create a new content model in the DedeCMS backend (e.g., "Products," "Downloads," "Staff Members"), DedeCMS creates a corresponding table in the database (like dede_addonproducts) to store the data for that specific model. The dede_field table tells DedeCMS what fields to create in that new table.

dede field name
(图片来源网络,侵删)

Structure of the dede_field Table

Here are the most important columns in the dede_field table and what they mean:

Column Name Data Type Description
id mediumint(8) unsigned Primary Key. A unique number for each custom field definition.
fieldset varchar(30) The name of the content model this field belongs to. This is the most important column for linking fields to a specific model.
fieldname varchar(50) The internal name of the field (e.g., price, rating, author_intro). This is what the system uses to reference the field.
dtype varchar(20) The data type of the field. Common values include: text (single line), textarea (multi-line), select (dropdown), radio (radio buttons), img (image upload), datetime (date and time), etc.
issystem smallint(1) A flag to indicate if it's a system field (1) or a user-defined field (0). Most of your custom fields will be 0.
fieldsetid smallint(5) unsigned The ID of the fieldset the field belongs to. This is used for organizing fields into groups on the editing page.
item text Stores options for fields like select, radio, or checkbox. For example, for a rating field, this might contain "5:Very Good,4:Good,3:Average,2:Bad,1:Terrible".
normbody text Default value for the field.
ifshow smallint(1) Whether the field is displayed on the frontend (the public-facing part of your website). 1 for yes, 0 for no.

How It Works: A Practical Example

Let's imagine you want to create a content model for "Book Reviews".

Step 1: Create the Content Model in DedeCMS Backend

  1. Go to 核心 -> 内容模型管理 -> 增加一个内容模型.
  2. Fill in the details:
    • 模型名称: Book Reviews
    • 模型表: dede_addonbook (DedeCMS will suggest this)
  3. Click "Submit".

Step 2: Add Custom Fields

  1. Go to 内容模型管理 -> 管理字段.
  2. You will see a dropdown for your new model ("Book Reviews"). Select it.
  3. Now, add the fields you need. For each field, you'll define its properties:
    • Field 1: "Book Author"
      • 字段名: book_author
      • : Book Author
      • 字段类型: text
    • Field 2: "My Rating"
      • 字段名: my_rating
      • : My Rating (out of 5)
      • 字段类型: radio
      • 字段参数: 5:Five Stars,4:Four Stars,3:Three Stars,2:Two Stars,1:One Star
    • Field 3: "Book Cover Image"
      • 字段名: book_cover
      • : Book Cover Image
      • 字段类型: img

What Happens in the Database?

  1. A new table named dede_addonbook is created. It will have the standard columns plus the new ones you defined: book_author, my_rating, and book_cover.
  2. Three new rows are added to the dede_field table:
    • One for book_author.
    • One for my_rating.
    • One for book_cover.
    • The fieldset column for all these rows will be 'book' (or whatever you named your model).

When you now go to write a new "Book Review," DedeCMS checks the dede_field table for all fields where fieldset = 'book' and displays them on the editing form based on their dtype and titlename.


Why is Understanding dede_field Important?

  1. Templating (Frontend Development): To display the content of a custom field in your template files (.htm), you use the field function. For example, to display the book author, you would use:

    {dede:field name='book_author'/}
  2. PHP Development: If you are writing a custom PHP script to get article data, you'll need to know the field names to query them from the corresponding addon table (e.g., dede_addonbook).

  3. Debugging: If a custom field is not showing up on the frontend or backend, the problem is often in the dede_field table. You might find:

    • The fieldset name is incorrect.
    • The ifshow value is 0.
    • The titlename is empty.
  4. Data Migration: When moving a DedeCMS site, you must not only back up the data tables (dede_archives, dede_addon*) but also the dede_field table, otherwise, you will lose all your custom field definitions.

-- 展开阅读全文 --
头像
c语言 gbk转unicode
« 上一篇 01-09
dede field body
下一篇 » 01-10

相关文章

取消
微信二维码
支付宝二维码

目录[+]