Of course! Let's break down the {dede:field.typeid/} and {dede:field.typelink/} tags in DedeCMS. They are fundamental for navigation and content categorization.

Summary
{dede:field.typeid/}: This tag outputs the ID number of the current article's category (e.g.,1,15,42). It's a value used for logic or identification.{dede:field.typelink/}: This tag outputs a complete, clickable HTML link to the current article's category archive page (e.g.,<a href='https://yourdomain.com/plus/list.php?tid=1'>Technology</a>). It's used directly in templates to display a link.
{dede:field.typeid/}
This tag is very simple. It retrieves and displays the numeric ID of the category that the current article belongs to.
How it Works
When you are viewing a single article page (e.g., article_article.php or view.php), DedeCMS knows which category that article is in. The typeid field holds that category's ID.
Example Usage
You would use this when you need the ID for other purposes, such as:
- Conditional Statements: Show different content based on the category ID.
{dede:field.name runphp='yes'} if(@me == '1') { @me = "<span class='label'>News</span>"; } else { @me = "<span class='label'>Article</span>"; } {/dede:field.name} - Passing an ID to another tag: For example, getting the parent category's ID.
{dede:field.typeid runphp='yes'} $id = @me; $row = $GLOBALS['dsql']->GetOne("SELECT reid FROM `dede_arctype` WHERE id='$id'"); @me = $row['reid']; {/dede:field.typeid} - Debugging: To quickly see which category ID an article is in.
{dede:field.typelink/}
This is one of the most commonly used tags for navigation. It automatically generates a hyperlink to the archive listing page for the article's category.

How it Works
- It gets the
typeidof the current article (just like the tag above). - It then uses this
typeidto look up the category's name and its URL path. - It combines these into a standard HTML
<a>link.
The resulting link typically points to plus/list.php?tid=[typeid].
Example Usage
This tag is perfect for displaying the article's category as a clickable link.
Basic Example:
<p>Category: <strong>{dede:field.typelink/}</strong></p>
If an article is in a category named "Technology" with ID 5, the output will be:

<p>Category: <strong><a href='/plus/list.php?tid=5' title='View all posts in Technology'>Technology</a></strong></p>
Advanced Usage (Styling the Link)
You can easily add CSS classes or other attributes to the link using DedeCMS's built-in attribute system.
Example with a CSS class:
<p>Category: {dede:field.typelink/}</p>
This will add a class category-link to the <a> tag, allowing you to style it with CSS:
<p>Category: <a href='/plus/list.php?tid=5' title='View all posts in Technology' class='category-link'>Technology</a></p>
Related and Useful Tags
When working with categories, you'll often see these tags used alongside typeid and typelink:
| Tag | Description | Example Output |
|---|---|---|
{dede:field.typeid/} |
ID of the current category. | 5 |
{dede:field.typelink/} |
Full link to the current category. | <a href='/plus/list.php?tid=5'>Technology</a> |
{dede:field.typename/} |
Name of the current category. | Technology |
{dede:geturl} |
URL of the current category (without the <a> tag). |
/plus/list.php?tid=5 |
{dede:field.position/} |
Breadcrumb navigation (home > parent > current category). | <a href='/'>Home</a> > <a href='/plus/list.php?tid=2'>News</a> > Technology |
Practical Example: Article Template (article_article.htm)
Here is a typical section of a single article template in DedeCMS showing how these tags work together.
<!DOCTYPE html>
<html>
<head>{dede:field.title/} - {dede:global.cfg_webname/}</title>
</head>
<body>
<h1>{dede:field.title/}</h1>
<!-- This is a common way to display article metadata -->
<div class="article-info">
<span>Author: {dede:field.writer/}</span> |
<!-- Using typelink to show the category as a clickable link -->
<span>Category: {dede:field.typelink/}</span> |
<span>Date: {dede:field.pubdate function="MyDate('Y-m-d', @me)"/}</span> |
<span>Views: {dede:field.click/}</span>
</div>
<hr>
<div class="article-content">
{dede:field.body/}
</div>
</body>
</html>
Important Note on SEO-Friendly URLs
By default, DedeCMS uses URLs like plus/list.php?tid=5. For better SEO, you should enable "Rewrite" in your DedeCMS后台 (Backend).
- Go to 系统 -> 系统基本参数 -> 核心设置 (System -> System Basic Settings -> Core Settings).
- Find the option 是否使用伪静态 (Use Pseudo-Static) and set it to "是" (Yes).
- Save and upload the
rewriterules for your server (.htaccessfor Apache,httpd.inifor IIS) to your website root.
After enabling rewrite, the URL for {dede:field.typelink/} will change from:
/plus/list.php?tid=5
to a more SEO-friendly version like:
/category/technology/ or /list/5.html
The {dede:field.typelink/} tag will automatically generate this new, friendly URL.
