Does the `categoryList` tag support custom sorting rules to display the category list? (The document does not directly mention it, but it can be explored)

Calendar 👁️ 72

As an experienced website operations expert, I know that how to flexibly display and organize content in a content management system is the key to improving user experience and SEO effects.AnQiCMS (AnQiCMS) provides a solid foundation for content operations with its efficient and customizable features.Today, let's delve deeply into the topic ofcategoryListThe core issue of the label: Does it support custom sorting rules to display the category list?

Anqi CMS category list label:categoryListOverview

In AnQi CMS,categoryListThe tag is a powerful tool that allows us to dynamically retrieve and display the list of website categories in the template.It allows us to flexibly call the classification information of articles or products according to different business scenarios, such as navigation menus, sidebar categories, home page category blocks, and so on.According to the provided document,categoryListThe basic usage of the label is usually like this:

{% categoryList categories with moduleId="1" parentId="0" %}
    {# 在这里循环输出分类信息 #}
{% endcategoryList %}

This tag supports passing throughmoduleId(Specify model ID, such as article or product),parentId(Specify parent category ID to get its subcategories, or0represents the top category),all(Get all categories),limit(Limit the number of displayed items) as well assiteIdParameters such as specifying a site in a multi-site environment are used to accurately locate the classification collection we need. These parameters undoubtedly provide convenience for the structured display of content.

Document Exploration: Where to find sorting parameters?

With doubts about the sorting rules of the category list, I carefully reviewed the detailed documentation of AnQiCMS aboutcategoryListthe detailed documentation of tags (tag-/anqiapi-category/151.htmlanddesign-tag.md)。It is noteworthy that in both of these concerningcategoryListThe description of the tag parameters does not explicitly mentionorderorsortThis parameter allows developers to directly specify the sorting rules of the category list at the template level, for example, in descending order by ID, in alphabetical order by name, etc.

This contrasts sharply with AnQiCMS'sarchiveListtags (used in document lists) clearly provideorderParameters, support sorting according to rules such as 'id desc' (latest documents), 'views desc' (most viewed), or 'sort desc' (custom sorting by backend) and so on.This indicates that AnQiCMS has differentiated sorting control methods for different types of lists during design.

Deep understanding of the classification and sorting mechanism: the control of the background 'display order'

ThoughcategoryListThe tag itself does not provide sorting parameters at the template level, but it does not mean that the category list is random or uncontrollable. In the AnQiCMS backend management interface, there is an important configuration item for each category - 'Display Order' (help-content-category.mdMentioned in the document. It is explicitly stated that the display order can determine the sorting of this category, the smaller the number, the earlier the display. The default value when created is 99.

This means that AnQiCMS mainly puts the sorting control of the category list onthe background management level. When we create or edit categories in the background, by setting a numeric value, we can determine the display position of the category among all同级 categories. The system callscategoryListWhen a label is displayed, it will default to the display order set by the background.This is a 'what you see is what you get' management style, which is more intuitive and easy to operate for non-technical personnel.

Adaptability: When the default sorting does not meet the needs

If the display order in the background cannot fully meet your specific needs on the front end, for example, if you want the same category list to have different sorting logic on different pages, or if you need to implement some dynamic, user-interactive sorting functions, we can consider the following strategies:

  1. Priority: Adjust the display order in the backgroundThis is the most direct and the original solution of AnQiCMS.For the vast majority of static sorting needs, simply log in to the backend, go to "Content Management" -> "Document Categories", edit the corresponding category, and adjust the "Display Order" value to an appropriate position.For example, if you want a category to always be at the top, you can set its display order to 0 or 1, ensuring that its value is less than that of other categories.This method is simple and effective, and it is SEO-friendly because it changes the default output order of categories.

  2. Custom sorting in front-end JavaScript (for specific scenarios)If your requirement is to implement someDynamic, interactiveThe sorting (for example, sorting by name when the user clicks the button, sorting by the most recent published, etc.), and these sorting logic does not need to be perceived by search engines, can be implemented through front-end JavaScript.

    • Steps:UsecategoryListThe label retrieves all categorized data to the front end (without concerning its initial order), and then uses JavaScript (such as Vue, React, or jQuery, etc.) to retrieve these DOM elements or data arrays and rearrange and render them according to the preset JavaScript sorting logic.
    • Consider:The disadvantage of this method is that it increases the complexity of the front-end, and since sorting occurs on the client side, search engine spiders may not be able to recognize the order of the dynamically sorted content, which is of limited help to SEO.
  3. Seek expansion or custom development (ultimate solution)For complex and deep-level sorting requirements, such as needing to sort based on the number of articles under a category, the value of a custom field, and requiring this sorting to beGenerated on the server and visible to SEOIf so, you may need to consider the secondary development of AnQiCMS or request official technical support. Modular design of Go language (AnQiCMS 项目优势.mdMentioned provides the possibility for this customization. This usually involves modifying the underlying data query logic or writing new template tags to meet specific sorting parameters.

Summary

In general, looking at AnQiCMS'scategoryListtags are not provided directly at the template levelorderorsortSpecify the sorting rules for the category list. Its core sorting mechanism depends on the "display order" field set in the background category management.This design philosophy simplifies the work of template developers, handing over most of the non-dynamic sorting control to content managers.For more advanced or dynamic sorting requirements, we can supplement with frontend JavaScript or consider customized development solutions when necessary.Understanding this mechanism can help us better utilize the existing functions of AnQiCMS and make good plans for future expansion.


Frequently Asked Questions (FAQ)

  1. Q:categoryListCan tags be likearchiveListdirectly specify the sorting method of the category through parameters? A:According to the official documentation of AnQiCMS,categoryListtags are currentlyDoes not support directlylikearchiveListsuch in the label throughorderorsortThe parameter specifies the sorting method for the category list. The default sorting of the category list is mainly determined by the "display order" field set for each category in the background management interface.

  2. Q: Have I set the display order value for categories in the background, and will the front-end category list be sorted immediately according to my settings? A:Will do. After you set the 'display order' for categories in the AnQiCMS backend, the system will use these numbers as the sorting basis by default.The smaller the number, the higher the position of the category in the list. If the front-end does not update immediately, please try to clear the AnQiCMS system cache or browser cache to ensure that the latest data is loaded.

  3. Q: How do I implement random sorting of a category list? A:AnQiCMS'categoryListThe tag itself does not provide the function of random sorting. To implement random sorting of category lists, you need to use front-end JavaScript. First, usecategoryListTag to get all category data, then write code in JavaScript to randomly shuffle the obtained category array, and finally render the sorted categories back to the page.Please note that this front-end random sorting is invisible to search engines and does not affect SEO rankings.

Related articles

If the category has not set Logo or Thumb, what path will `categoryList` return, and how to set the default image?

In the daily operation of AnQiCMS, fine-grained content display is a key factor in improving user experience and the professionalism of the website.The importance of images as visual elements is self-evident.However, many operators may encounter the situation that the Logo or Thumb image of the category is not set when calling the category information using tags like `categoryList`, which may cause blank or broken images to be displayed on the front end.Today, let's delve deep into this issue and provide an elegant solution.

2025-11-06

In multi-site management, how do you call the category data under other sites using `categoryList`?

As an experienced website operations expert, I am well aware that how to efficiently manage content and achieve data interconnectivity in a complex website ecosystem is the key to improving operational efficiency.AnQiCMS (AnQiCMS) with its powerful multi-site management capabilities, provides us with such possibilities.Today, let's delve into a very practical scenario in multi-site operations: how to elegantly call the classification data under other sites using the `categoryList` tag.### AnQi CMS Multi-Site Management: `categoryList`

2025-11-06

How to use the "offset,limit" mode in the `limit` parameter supported by `categoryList`, and what scenarios are applicable?

## Masterful Manipulation of Category List: Practical Use of AnQiCMS `categoryList`'s `offset,limit` Pattern As an experienced website operations expert, I am well aware of how important flexible data display capabilities are when building and optimizing website content.AnQiCMS with its concise and efficient features provides us with many powerful template tags, among which the `categoryList` tag is the core tool for managing website classification content. Today

2025-11-06

How to get the category details information of a specified ID through the `categoryList` tag instead of the current page?

As an experienced website operations expert, I know how important it is to flexibly obtain and display data when managing content.Especially when building the AnQiCMS website, we often encounter situations where we need to obtain specific category information rather than the context of the current page.Today, let's delve deeply into how to cleverly use AnQiCMS template tags to accurately obtain the category details you want.How to accurately locate: How to get the category details of a specified ID instead of the current page?In AnQiCMS template development, `categoryList` and

2025-11-06

How to avoid `categoryList` automatically reading the current page category ID and force it to only display top-level categories?

In the flexible content management world of Anqi CMS, template tags are the bridge between us and data interaction.Among them, the `categoryList` tag is undoubtedly one of the core tools for building website navigation and content lists.However, senior operators often encounter a scene: when the website is on a specific category page, the `categoryList` tag will 'intelligently' read the current category ID and use it as the context for data display.This is extremely convenient in many cases, such as displaying the subcategories or peer categories of the current category.

2025-11-06

When will the `item.Content` field be used in the `categoryList` loop, can it display rich text content?

HelloAs an experienced website operations expert, I am willing to deeply analyze the application of the `item.Content` field in the `categoryList` loop of AnQiCMS (AnQiCMS), as well as how to elegantly display rich text content.

2025-11-06

`categoryList` can exclude certain specific category IDs from displaying in the list?

As an experienced website operations expert, I know how important it is to have fine control over the list content in content management.Especially in the context of increasingly complex website structures and increasingly rich content, how to flexibly display or hide specific content is directly related to user experience and operational efficiency.Today, let's delve into a common but cleverly handled requirement in AnQiCMS (`categoryList` tag) - whether it can exclude certain specific category IDs from displaying in the list.###

2025-11-06

How to use `categoryList` to build a flat list of all categories without hierarchy display?

As an experienced website operation expert, I know how important it is to flexibly display category lists when building website content structure.AnQiCMS (AnQiCMS) has provided us with great convenience with its powerful template tag system.Today, let's delve into a seemingly simple yet extremely practical feature: how to elegantly build a flat list of all categories using the `categoryList` tag, so that all categories are clearly displayed on your website without any hierarchy.Why do we need a flat category list?

2025-11-06