As an experienced website operation expert, I know that how to flexibly display and organize content is the key to improving user experience and SEO effectiveness in content management systems.AnQiCMS (AnQi CMS) provides a solid foundation for content operations with its efficient and customizable features.categoryListThe core issue of the tag: Does it support custom sorting rules to display the category list?
The category list tag of Anqi CMS:categoryListOverview
In the Anqi CMS,categoryListTags are a powerful tool for dynamically retrieving and displaying the website category list in our templates.It allows us to flexibly call the classification information of articles or products according to different business scenarios, such as navigation menus, sidebar categories, homepage category blocks, etc.categoryListThe basic usage of the tag is usually like this:
{% categoryList categories with moduleId="1" parentId="0" %}
{# 在这里循环输出分类信息 #}
{% endcategoryList %}
This tag supports throughmoduleId(specifying a model ID, such as an article or product),parentId(specifying a parent category ID to get its subcategories, or)0to indicate a top-level category),all(to get all categories),limit[Limited Display Quantity] as well assiteIdUsing parameters such as (site-specific in a multi-site environment) to accurately locate the classification set we need. These parameters undoubtedly provide convenience for the structured presentation 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 tags (tag-categoryList.mdanddesign-tag.md)It is noteworthy that in these two documents aboutcategoryListthere is no explicit mention oforderorsortSuch parameters allow developers to directly specify the sorting rules for the category list at the template level, for example, by ID in descending order, by name in alphabetical order, etc.
In stark contrast, the value provided by AnQiCMS isarchiveListTags (used for document lists) explicitly provideorderParameters support sorting by rules such as 'id desc' (latest documents), 'views desc' (most views), or 'sort desc' (custom sorting by backend).This indicates that AnQiCMS differentiates the sorting control methods for different types of lists during design.
A deep understanding of the classification and sorting mechanism: the control power of the 'Display Order' in the background
AlthoughcategoryListThe label 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, for each category, there is an important configuration item - 'Display Order' (help-content-category.mdIt is mentioned. The document explicitly states: "The display order determines the sorting of this category, with lower numbers appearing earlier by default. The default value is 99 when created by default."
This means that AnQiCMS mainly puts the control of the sorting of the category list on theback-end management levelWhen creating or editing categories in the background, by setting a numeric value, you can determine the display position of the category among all同级分类. The system callscategoryListWhen labeling, it will default to displaying according to these "display order" settings set in 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 requirements
If the 'Display Order' in the backend cannot fully meet your specific display 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 features, we can consider the following strategies:
Priority: Adjust the background "Display Order"This is the most direct and the original intention of AnQiCMS design.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 SEO-friendly, as it changes the default output order of the categories.
Front-end JavaScript Custom Sorting (Applicable to Specific Scenarios)If your requirement is to implement someDynamic and interactiveThe sorting (for example, sorting by user button clicks by name, by the latest published, etc.), and these sorting logic does not need to be perceived by search engines, can be implemented through front-end JavaScript.
- Step:Use
categoryListThe label retrieves all category data to the front end (without concerning its initial order), then uses JavaScript (such as Vue, React, or jQuery, etc.) to obtain these DOM elements or data arrays, and rearranges and renders them according to the predefined JavaScript sorting logic. - Consideration: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 crawlers may not be able to recognize the content order after this dynamic sorting, which is of limited help to SEO.
- Step:Use
Seek for expansion or customization development (ultimate solution)For those complex and deep-level sorting requirements, such as needing to sort dynamically 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 secondary development of AnQiCMS or request official technical support. Modular design of Go language (
AnQiCMS 项目优势.mdThis involves modifying the underlying data query logic or writing new template tags to meet specific sorting parameters.
Summary
Overall, AnQiCMS'scategoryListtags are not provided directly at the template levelorderorsortSpecify the sorting rules for the category list using parameters.Its core sorting mechanism relies on the 'Display Order' field set in the background category management.This design concept simplifies the work of template developers, transferring the control of most non-dynamic sorting to content administrators.For more advanced or dynamic sorting requirements, we can supplement with frontend JavaScript or consider customized development solutions if necessary.Understanding this mechanism can help us better utilize the existing features of AnQiCMS and plan for future expansions.
Common Questions and Answers (FAQ)
Q:
categoryListCan tags be likearchiveListspecified directly through parameters to determine the sorting method of the category? A:According to the official document of AnQiCMS,categoryListtags are currentlynot directly supportedlikearchiveListthat inside the tagorderorsortParameters specify the sorting method of 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.Q: Have I set the "display order" value for categories in the background, and will the category list on the front end be sorted immediately according to my settings? A:Will do.When 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 value, the higher the position of the category in the list.If the front-end does not update immediately, please try clearing the AnQiCMS system cache or browser cache to ensure that the latest data is loaded.
Q: How can I implement random sorting of a categorized list? A:AnQiCMS
categoryListThe tag itself does not provide random sorting functionality. To achieve random sorting of the category list, you need to complete it through front-end JavaScript. First usecategoryListRetrieve all category data with tags, then write code in JavaScript to shuffle the retrieved category array randomly, and finally re-render the sorted categories on the page.Please note that this frontend random sorting is invisible to search engines and will not affect SEO rankings.