dede field.typeid是什么?如何获取分类ID?

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

Of course. Let's break down dede_field.typeid in detail. This is a fundamental concept for understanding how data is stored and managed in the DedeCMS (织梦内容管理系统) database.

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

What is dede_field?

In DedeCMS, content is not stored in a single, massive article table. Instead, it uses a normalized database structure to provide flexibility.

  • dede_archives: This table stores the common fields for every piece of content, regardless of its type. Examples include:

    • id (the content ID)
    • typeid (the category ID)
    • title (the article title)
    • pubdate (the publication date)
    • click (the view count)
    • ismake (whether it's generated to static HTML)
  • dede_arctype: This table stores information about the categories (频道模型). Each category has an id and a typename.

  • dede_field: This is the key table for custom fields. It defines the structure of the additional data that can be added to different content models. It doesn't hold the actual content itself, but rather the "blueprint" for the fields.

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

What is typeid in the dede_field table?

The typeid column in the dede_field table is a foreign key that links a custom field definition to a specific category (channel model) in DedeCMS.

Its primary purpose is to answer the question: "To which category or model does this custom field belong?"

  • typeid = 0: This is a special and very common value. It means the custom field is a global field. It will be available for use in all content models across the entire website.
  • typeid > 0: This means the custom field is specific to a single category or model. The value of typeid corresponds to the id of a category in the dede_arctype table. This field will only appear in the content editing form for articles that belong to that specific category.

How typeid is Used: The Workflow

Let's walk through an example to make this crystal clear.

Scenario: You have a news website with two main categories:

  1. "Product Reviews" (Category ID: 5)
  2. "Company News" (Category ID: 6)

You want to add different custom fields to each:

  • For "Product Reviews", you need a field for Product_Price and Product_Rating.
  • For "Company News", you need a field for Author_Name.

Here's how you would use typeid:

Step 1: Define the Fields in the DedeCMS Backend

  1. Go to "核心" -> "内容模型管理" -> "添加新模型" or "修改现有模型".

  2. For the "Product Reviews" model (which corresponds to typeid=5):

    • You add a new custom field named Product_Price. In the database, a new row is created in dede_field:
      • field (the name): Product_Price
      • typename (the display name): 产品价格
      • typeid: 5
    • You add another custom field named Product_Rating. In the database:
      • field: Product_Rating
      • typename: 产品评分
      • typeid: 5
  3. For the "Company News" model (which corresponds to typeid=6):

    • You add a new custom field named Author_Name. In the database:
      • field: Author_Name
      • typename: 作者姓名
      • typeid: 6

Step 2: The Database (dede_field Table)

Your dede_field table would now have rows like this:

id field typename typeid
1 Product_Price 产品价格 5
2 Product_Rating 产品评分 5
3 Author_Name 作者姓名 6
4 source 来源 0

Step 3: Editing Content

When a logged-in admin user goes to create a new article:

  • If they select the "Product Reviews" category (typeid=5), the content editing form will automatically show the fields "产品价格" and "产品评分".
  • If they select the "Company News" category (typeid=6), the form will show the field "作者姓名".
  • Both forms will also show the global field "来源" because its typeid is 0.

Relationship with dede_archives.typeid

It's crucial not to confuse dede_field.typeid with dede_archives.typeid.

  • dede_field.typeid: Defines which model/category a custom field belongs to. It's part of the schema or structure.
  • dede_archives.typeid: Stores the actual category of a specific piece of content. It's part of the data.

When an article is saved, its typeid in dede_archives tells the system which set of custom fields (defined by dede_field.typeid) should be used to save the extra data.

Summary

Column/Table Purpose Example Value
dede_field.typeid Links a custom field definition to a content model/category. 0 (global), 5 (Product Reviews), 6 (Company News)
dede_arctype.id The unique ID for a category/content model. 5, 6
dede_archives.typeid Stores the category ID for a specific published article. 5 (if an article is in the "Product Reviews" category)

In short, dede_field.typeid is the essential column that makes DedeCMS's custom field system powerful and organized, allowing you to have different data fields for different types of content on your site.

-- 展开阅读全文 --
头像
dede_arctiny是什么?有什么用?
« 上一篇 2025-12-19
dede pagelist不显示怎么办?
下一篇 » 2025-12-19

相关文章

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

目录[+]