When operating a website, we often encounter such needs: when displaying the website category list, we hope to see directly how many articles are under each category.This not only helps visitors quickly understand the richness of a topic's content, improve user experience, but also allows content operators to better plan content strategies, and even has its unique value in SEO optimization.

Then, does AnQiCMS support displaying the number of articles under each category on the category list page? The answer is yes, and it is very convenient to implement.

In AnQiCMS template design, if you want to clearly display how many articles are included under each category in the category list page, it is actually very intuitive.This is mainly due to the powerful and flexible template tag system of AnQiCMS.Built-in systemcategoryListThe tag is designed to obtain the category list, and it also thoughtfully includes the number of articles under each category when returning each category information.

In particular, when you loop through the category list in a template, for example, using{% categoryList categories with ... %}such tags to get the category data,categorieseach variable initemEach one represents a specific category and carries rich classification information. Among them, there is one namedArchiveCountThe field. This field accurately records the total number of documents under this category (including its subcategories).

This means that you do not need to perform additional database queries or complex logical processing. When you retrieve and display category names, category links, and other information in the template, you simply need to call{{ item.ArchiveCount }}It can display the corresponding number of articles on the page, for example, showing as "Technical Articles (123)" or "Product Cases (45)."}This built-in support greatly simplifies the development and maintenance workload.

It is worth mentioning,categoryListThe tag itself supports various parameters to finely control the range of categories obtained, such as bymoduleIdTo specify the retrieval of only specific content models (such as article models or product models) categories, or byparentIdLimit to retrieve only the child categories under a certain parent category. No matter how you filter and organize the categories,ArchiveCountthe field will provide the exact number of articles under the corresponding category.

This is not just a technical convenience, but also a profound understanding of the actual needs of website operation.Clear number display of articles, can guide users to discover more interesting content, reduce the bounce rate;At the same time, it also helps content operators to quickly identify which categories are hot topics and which may have sparse content and need to be supplemented, thus more efficiently adjusting content updates and promotion strategies.This out-of-the-box capability is exactly the embodiment of AnQiCMS' commitment to providing an efficient, customizable, and easy-to-expand content management solution.

In essence, AnQiCMS, with its carefully designed template tags and flexible content model, makes it a simple and practical feature to display the number of articles on the category list page, effectively supporting the management and presentation of website content.


Frequently Asked Questions (FAQ)

  1. Is this article count statistics updated in real time?Yes, in AnQiCMSArchiveCountThe field is dynamically retrieved, it will query the number of articles under this category in the database in real time.This means that after you publish, delete, or move an article, the number of articles displayed on the category list page will be updated immediately to ensure the accuracy of the information.

  2. If there are no articles under a category currentlyArchiveCountwhat will be displayed?If there are currently no articles under a category,ArchiveCountIt will be displayed naturally0. You can make a judgment in the template based on this value, for example, ifArchiveCountFor 0, you can choose not to display the article count or show prompts like 'No articles' to keep the page neat or provide a more friendly user hint.

  3. Can I incategoryListCount the number of categories under a specific content model (such as 'product' rather than 'article')?Absolutely.categoryListTag supportmoduleIdParameters, you can go throughmoduleId="1"(Assuming the ID of the article model is 1) ormoduleId="2"(Assuming the product model ID is 2) to specify the category list you want to retrieve. This is, ArchiveCountThe field will only count the number of articles under the specified model, providing you with more accurate content statistics.