dede arcrank 2

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

Of course. Let's break down what dede arcrank -2 means in the context of the Dedecms (DedeCMS) content management system.

dede arcrank 2
(图片来源网络,侵删)

This is a very common and powerful parameter used in the DedeCMS template engine.

In a Nutshell

dede arcrank -2 is a tag attribute used to fetch and display content from the DedeCMS database. The -2 specifically means: "Show me all articles, regardless of their 'arcrank' status, EXCEPT for those that are deleted (arcrank = -2)."


Detailed Breakdown

To fully understand this, let's look at the three components:

dede

This is the namespace prefix for all DedeCMS template tags. It tells the DedeCMS parser that this is a system tag. You'll see it in many other tags like {dede:arclist}, {dede:channel}, {dede:field}, etc.

dede arcrank 2
(图片来源网络,侵删)

arcrank

This is the most important part. arcrank is a database field in the dede_archives table (the main table for articles in DedeCMS). It's a small integer that acts as a status flag for an article.

Here are the common values for arcrank and what they mean:

arcrank Value Status Name Description
0 Normal (默认) This is the default status. The article is visible to all public visitors on the website.
-1 Pending Review (待审核) The article has been submitted but is waiting for an administrator to approve it. It is not visible to the public.
-2 Deleted (删除) The article has been deleted from the public view. It's typically moved to a "recycle bin" and is not visible to the public.
1, 2, 3... Special Levels (特殊级别) These are custom levels used by some DedeCMS plugins or custom logic. They are often used for premium, member-only, or other non-public content.

-2 (The Value)

When you use arcrank="-2" in a tag, you are setting a filter on the query. The DedeCMS system will then add a WHERE clause to its SQL query.

  • arcrank='-2': This would fetch only the articles that have been deleted.
  • arcrank='0': This would fetch only the normal, public articles.
  • arcrank='-1': This would fetch only the articles pending review.

The Special Case of arcrank="-2" in a List Tag

This is where it gets interesting and is the most common use case. When you use arcrank="-2" inside a list-generating tag like {dede:arclist} or {dede:sql}, it has a special meaning.

It's interpreted as: "Exclude articles with arcrank = -2".

It's a shortcut for writing a more complex condition. The system essentially does this:

-- The actual logic behind arcrank="-2"
SELECT * FROM dede_archives WHERE arcrank <> -2
-- Or sometimes:
SELECT * FROM dede_archives WHERE arcrank IN (0, -1, 1, 2, ...) 

This is extremely useful because it's a simple way to say, "Show me everything that hasn't been permanently deleted," which is usually what you want on a public-facing page.

Practical Examples

Example 1: Displaying All Public and Pending Articles on the Frontend

Imagine you have a page that lists all submitted content, whether it's been approved or not (maybe for a moderator's dashboard). You want to exclude only the deleted articles.

{dede:arclist titlelen='30' row='10' arcrank='-2'}
    <li>
        <a href="[field:arcurl/]">[field:title/]</a>
        <span>状态: [field:arcrank function="GetArank(@me)"/]</span>
    </li>
{/dede:arclist}

In this example, arcrank="-2" ensures that deleted articles (arcrank = -2) are not shown. Articles with arcrank = 0 (Normal) and arcrank = -1 (Pending) will be displayed.

Example 2: Displaying ONLY Normal, Public Articles

If you want to show only the articles that are live for the general public, you would explicitly set arcrank="0".

{dede:arclist titlelen='30' row='10' arcrank='0'}
    <li><a href="[field:arcurl/]">[field:title/]</a></li>
{/dede:arclist}

This is the most common configuration for a standard news or blog page.

Summary

Attribute Meaning Use Case
arcrank='0' Show only normal, public articles. Standard public news/blog pages.
arcrank='-1' Show only articles pending review. A backend moderation queue.
arcrank='-2' Show all articles except deleted ones. A general content list where you want to avoid showing trash.
arcrank='1' Show only articles with a special rank of 1. A premium content or member-only section.
(No arcrank attribute) Show all articles (including deleted ones). Very rare, typically used for administrative or backup purposes.

In conclusion, dede arcrank -2 is a filter that tells DedeCMS to pull all content except for the items that have been marked as deleted. It's a convenient way to ensure your public pages are clean and only show relevant content.

-- 展开阅读全文 --
头像
织梦辅助插件上传文件夹
« 上一篇 01-08
powered by dede
下一篇 » 01-08

相关文章

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

目录[+]