As an experienced website operations expert, I fully understand the intuitive needs of content publishers for 'previous article' and 'next article' navigation and the logic behind it. In AnQiCMS (AnQiCMS),prevArchiveTags are designed to meet such needs. However, regarding the basis for determining the 'previous' document - whether it is based on ID, time, or sorting field, this is indeed a topic worth in-depth discussion.
To understandprevArchiveThe operation mechanism of the label, we first need to clarify a core fact:prevArchiveThe label itself does not accept any parameters to specify the sorting rule.This means, it will not directly let you tell it 'Please find the previous one according to the ID' or 'Please find the previous one according to the publication time'.Its judgment is more of a 'wisdom' based, dynamic response based on context.
Where does this 'wisdom' manifest? In short,prevArchiveThe basis for the label to judge the 'previous article' document isIt depends on the current list environment (if any) and the sorting rules set by that environment.
Let's break down this process step by step:
The context takes precedence: the sorting rule of the list is dominant
When a document is accessed, if it is clicked into from a specific document list (such as, article classification list, tag article list, etc.), then this list is usually accessed through AnQiCMS.archiveListGenerate a tag. AndarchiveListTags are supported throughorderParameters to specify the sorting method. For example:
order="id desc": Sort by document ID in reverse order (the latest released ID is the largest, and it is ranked in front).order="views desc": Sorted in descending order by view count (the most viewed items are at the top).order="sort desc": Sorted in descending order by a custom sorting field on the backend (usually manually set by operations staff).
In this case,prevArchiveThe label will cleverly follow the sorting rules currently adopted by the list. If your category list is sorted by publish time (corresponding to
标签会非常聪明地遵循当前列表所采用的排序规则。如果你的分类列表是按照发布时间(对应
标签会非常聪明地遵循当前列表所采用的排序规则。如果你的分类列表是按照发布时间id descorcreatedTime desc) In reverse order, the "Previous" article would naturally be the one that is "earlier" or has a smaller "ID" in the list. Similarly, if the list is sorted by the number of views,prevArchiveWe can find a document with a higher level of page views than the current document as the 'previous article'.
It can be said,prevArchiveThe label's behavior is 'responsive', respecting the document order expected by the content operator when building the list.
2. Default behavior: When there is no explicit context.
However, not all documents are always accessed in a clear list with a specific sorting rule.Sometimes, users may directly access a document detail page through a link, or enter from the search engine results page.In the absence of explicit list context,prevArchiveHow does the tag determine 'previous article'?
At this moment, AnQiCMS will use a set of default sorting logic to determine the relative position of the document. According toarchiveListLabel documentation, if not specifiedorderparameters,“Default custom sorting”. This “custom sorting” usually refers to the document configuration in the background management interfacesortThe field. Operators can set a sorting value for each document in the background, with smaller numbers appearing earlier. IfsortThe field is not set, the system may further revert to the default logic based on document ID or creation time (usually in reverse ID order, i.e., the latest).
Therefore, when there is no explicit list sorting context,prevArchivetends to refer to the custom sorting field in the backgroundsortThe document ID or publication time determines which one is the previous article.This ensures that even in the most extensive access scenarios, the relative navigation between documents remains logical and predictable.
3. Comprehensive consideration of ID, time, and sorting field
In summary,prevArchiveThe label judgment of the "previous" document is not based on a single ID, time, or sorting field, but on a dynamic, step-by-step comprehensive consideration process:
- The primary basis: The document is located inSorting rules of the explicit list(Through
archiveListoforderParameter specified, such asid desc/views desc/sort desc) - Secondary basis (default fallback)If the document does not have an explicit list context or the list does not specify a sorting rule, the system will default tothe default custom sorting (
sort desc)This may follow with document ID or reverse chronological creation time.
This design makes the document navigation of AnQiCMS both flexible and intelligent. Operators can accessarchiveListThe label precisely controls the sorting of the list, thereby indirectly affectingprevArchiveandnextArchiveThe behavior; at the same time, the system also provides a reasonable default fallback mechanism to ensure the availability of navigation functions in various scenarios.
Frequently Asked Questions (FAQ)
1. Can I directly go in.prevArchiveLabel the sorting method, for example, to find the previous one only based on the publish time?
Answer: prevArchiveThe tag does not accept any parameters to specify the sorting method. Its behavior is determined by the context of the current document (such as the parent list). If you wishprevArchiveNavigate by publish time, you need to make sure that the list of current documents (such as category lists) includes byarchiveListtags and setorder="id desc"(ID is usually closely related to the publication time, the larger the ID, the later the publication time) for sorting.
2. If my website does not set anyorderparameter,prevArchiveWhat determines the label for "Previous"?
Answer:Without explicit settingorderIn the context of the parameter list, AnQiCMS will follow its default sorting logic. According to the document, this default logic is to sort according tocustom sorting field in the background(order="sort desc")To determine the document order. If the custom sorting field has not been set or is the default value, the system will usually further revert to the logic based on document ID (in reverse order) or creation time (in reverse order), that is, the most recently published documents are listed first.
3. How to makeprevArchiveandnextArchiveThe navigation order of the tags matches the document order I manually adjusted in the background?
Answer:The most direct and recommended method to achieve this goal is to explicitly use when generating the document list.archiveListtags and setorder="sort desc"Parameters. The AnQiCMS backend usually has a "Sort" or "Display Order" field for operators to manually adjust the priority of documents. When the list is sorted in reverse order by this field,prevArchiveandnextArchiveIt will follow the manual order you set in the background.