Of course! Let's break down dede_arctype in detail. This is one of the most important and frequently used tables in the DedeCMS system.

What is dede_arctype?
In simple terms, dede_arctype is the database table that stores all the information about your website's categories (also known as "channels" or "arcsorts" in DedeCMS).
Every time you create or edit a category in your DedeCMS backend, you are adding or modifying a record in this table. It's the foundation for organizing your content, from news articles to product listings.
Key Fields in the dede_arctype Table
Understanding the structure of this table is crucial for developers and advanced users. Here are the most important fields:
| Field Name | Data Type | Description |
|---|---|---|
id |
mediumint(8) unsigned |
Primary Key. The unique ID number for the category. This is the most common way to refer to a specific category. |
reid |
mediumint(8) unsigned |
Parent ID. This is the key to building the category tree. It stores the id of the parent category. If reid is 0, it means this is a top-level (main) category. |
topid |
mediumint(8) unsigned |
The ID of the top-level parent category. Useful for quickly identifying the root of any nested category. |
sortrank |
smallint(5) unsigned |
Sort Order. A number used to determine the order of categories. Categories are sorted by this number in ascending order (lower numbers appear first). If two categories have the same sortrank, they are sorted alphabetically by typename. |
typename |
varchar(50) |
The Category Name. This is the human-readable name of the category that appears on your website (e.g., "Company News", "Product Tutorials"). |
typedir |
varchar(100) |
Category Directory. The folder path where articles in this category will be stored. This is used to generate the URL for the category list page. It can contain placeholders like {typedir} and {Y}, {M}, {D} for date-based folders. |
isdefault |
smallint(1) |
Default Channel. 1 means this category is the default channel for its type. When you create an article and don't specify a category, it might go here. |
defaultname |
varchar(50) |
The default name for the list page of this category (e.g., index.html). |
issend |
smallint(1) |
Can members submit articles to this category? 0 for No, 1 for Yes. |
channeltype |
smallint(1) |
The type of channel this category belongs to (e.g., 1 for article channel, 2 for image channel, etc.). |
moresite |
smallint(1) |
Enable multi-site for this category? 0 for No, 1 for Yes. |
description |
varchar(255) |
A short description of the category, often used for SEO meta descriptions. |
keywords |
varchar(255) |
Keywords associated with the category, often used for SEO meta keywords. |
seotitle |
varchar(80) |
A custom SEO title for the category page, which overrides the typename in the page <title> tag. |
**mod |
varchar(50) |
The model (template) used for the category list page. |
templist |
varchar(80) |
The template file for the category list page (e.g., list_article_channel.htm). |
temparticle |
varchar(80) |
The template file for the article detail page within this category. |
namerule |
varchar(50) |
The URL naming rule for articles in this category (e.g., {aid} for article_view.php?id=123, or {typedir}/{aid}.html for pretty URLs). |
namerule2 |
varchar(50) |
The URL naming rule for the category list page itself. |
ispart |
smallint(1) |
Is this a "channel" type category (can have its own homepage) or a regular sub-category? 1 for channel, 0 for sub-category. |
corank |
smallint(5) unsigned |
Used for co-occurrence ranking in related articles. |
description2 |
varchar(255) |
An extended description field, often used for more detailed content or in templates. |
How is dede_arctype Used? (Common Scenarios)
Content Organization (The Primary Purpose)
This is the core function. You create a hierarchy of categories.

- Example:
reid=0:News(ID: 1)reid=1:Company News(ID: 2)reid=1:Industry News(ID: 3)reid=2:Press Releases(ID: 4)
When you add an article, you assign it to one of these categories (e.g., ID 4). DedeCMS then knows exactly where to place it in your site structure.
Generating Category URLs
The typedir and namerule2 fields are critical for URL generation.
typedir: If you settypedirtoa/{typedir}for the "Company News" category (ID: 2), DedeCMS will create a physical directory like/a/CompanyNews/.namerule2: If you set this toindex_{page}.html, the URL for the second page of the "Company News" list will be/a/CompanyNews/index_2.html.
Template Development (Using {dede:channel} and {dede:sonchannel} tags)
When building your website's navigation menu, you will constantly query this table, usually through DedeCMS's built-in template tags.
-
{dede:channel}: This tag fetches categories from thedede_arctypetable.
(图片来源网络,侵删)- By default, it gets all top-level categories (
reid=0). - You can specify a parent to get its children:
{dede:channel reid='1'}gets all sub-categories of the category withid=1. - Example (Main Navigation):
<nav> <ul> {dede:channel type='top' row='8'} <li><a href="[field:typelink/]">[field:typename/]</a></li> {/dede:channel} </ul> </nav>
- By default, it gets all top-level categories (
-
{dede:sonchannel}: This is a shortcut to get the direct children of a specific category.- Example (Sub-category menu under "News"):
{dede:sonchannel rsort='sortrank' row='8'} <a href="[field:typelink/]">[field:typename/]</a> {/dede:sonchannel}
- Example (Sub-category menu under "News"):
PHP Development (Direct Database Queries)
For custom PHP code or plugin development, you might need to query this table directly.
<?php
// Require the DedeCMS configuration file
require_once (dirname(__FILE__) . "/include/config.php");
// Connect to the database
$dsql = new DedeSql(false);
// --- Example 1: Get all top-level categories ---
$dsql->SetQuery("SELECT id, typename, typedir FROM `#@__arctype` WHERE reid=0 ORDER BY sortrank ASC");
$dsql->Execute('top');
echo "<ul>";
while ($row = $dsql->GetArray('top')) {
echo "<li><a href='{$row['typedir']}'>{$row['typename']}</a></li>";
}
echo "</ul>";
// --- Example 2: Get all sub-categories of a specific category (e.g., ID = 5) ---
$parent_id = 5;
$dsql->SetQuery("SELECT id, typename, typelink FROM `#@__arctype` WHERE reid={$parent_id} ORDER BY sortrank ASC");
$dsql->Execute('sub');
if ($dsql->GetTotalRow() > 0) {
echo "<h3>Sub-Categories:</h3>";
echo "<ul>";
while ($row = $dsql->GetArray('sub')) {
// Note: typelink is a virtual field, you might need to construct it manually
$typelink = $GLOBALS['cfg_cmspath'] . '/' . $row['typedir'] . '/';
echo "<li><a href='{$typelink}'>{$row['typename']}</a></li>";
}
echo "</ul>";
}
$dsql->Close();
?>
Relationship with Other Tables
dede_arctype doesn't exist in a vacuum. It's linked to other core tables:
#@__archives: This table stores your articles. Thetypeidfield in#@__archivesis a foreign key that points to theidfield in#@__arctype. This is how an article knows which category it belongs to.#@__arccattag: A linking table that connects articles (aid) to multiple categories (typeid). This allows an article to be in more than one category.#@__channeltype: Defines the different content models (Article, Image, Download, etc.). Thechanneltypefield indede_arctypelinks to this table.
Summary
| Aspect | Description |
|---|---|
| What it is | The central database table for storing all category information in DedeCMS. |
| Key Purpose | To organize content into a hierarchical structure and control its display. |
| Most Important Fields | id (unique identifier), reid (parent ID for hierarchy), typename (visible name), typedir (URL path). |
| How it's Used | By the backend for content management, by the template engine ({dede:channel}) for building navigation, and by developers for custom functionality. |
| Core Relationship | Links to #@__archives via the typeid field to associate articles with categories. |
Understanding dede_arctype is fundamental to mastering DedeCMS, as it underpins the entire content organization and navigation system of your website.
