How to display subcategories on the category page, or show the article list when there are no subcategories?

Calendar 78

In website operation, the content display logic of the category page has an important impact on user experience and information architecture.We often encounter such needs: when there are subcategories under a category, it is preferable to display these subcategories to facilitate more detailed navigation;And if the category does not have any subcategories, then directly display the list of articles under the category, to avoid the page content being empty or the navigation hierarchy being too deep.AnQiCMS (AnQiCMS) provides flexible template tags that can easily achieve this dynamic display effect.

Understanding the dynamic display logic of the category page

To implement the intelligent display of the category page, the core lies in determining whether the current category has subcategories. Based on the judgment result, we adopt different display strategies:

  1. If there are subcategories:Display all subcategories under the current category, usually presented in a list or card format, guiding users to more specific categories.
  2. If there are no subcategories:Display the list of articles included in the current category, allowing users to browse the content directly.

This design can effectively improve the usability of the website, allowing users to find valuable information at any level of the category page, rather than seeing an empty page.

The key template tag for dynamic display in Anqi CMS

The AnQi CMS template system is based on the Django template engine syntax, providing powerful tag functions for data retrieval and processing. To implement the above logic, we need to use the following core tags:

  1. categoryDetailTags:Used to obtain the details of the current category. We can use it to obtain the ID of the current category to pass as a parameter to other tags.

    • Usage example: {% categoryDetail currentCategory %}(Get the complete object of the current category) or{% categoryDetail currentCategoryId with name="Id" %}(Only get the ID of the current category).
  2. categoryListTags:Used to get the category list, which is the key we use to find subcategories.

    • Main parameters:
      • parentId: Specify the parent category ID to retrieve its direct subcategories. When used on the category page, if the current category ID is passed in, it can obtain all subcategories of the current category.
      • moduleId: Specify the content model ID to ensure that the classification of a specific model is obtained (such as article model, product model).
    • Return properties:While traversingcategoryListreturneditem, each classification item includesId/Title/Linkand other information.
  3. archiveListTags:Used to retrieve a list of articles (or any content under a document model).

    • Main parameters:
      • categoryId: Specify the category ID to get articles under the specified category.
      • type: Usually set to"list"(to get a fixed number) or"page"Get a paged list.
      • limit: Limit the number of articles.
    • Return properties:TraversalarchiveListreturneditemEach article item includes whenId/Title/Link/Description/Thumband other information.

4

Related articles

How to retrieve and display the list of all categories on the website?

In Anqi CMS, the website category list is the foundation for building clear navigation, enhancing user experience, and optimizing search engine rankings.Whether it is to establish a classification system for articles, products, or other content models, AnQiCMS provides flexible and powerful tools to easily obtain and display these classifications.One of the core concepts of AnQiCMS is to make content management efficient.It organizes the content into different "content models", such as common article models and product models.Each content model can have an independent classification system. Understanding this is the first step to obtaining the classification list.

2025-11-09

How to display a list of recommended articles related to the current article?

In website operation, recommending relevant articles to readers is an important strategy to enhance user experience, prolong user stay time, and optimize SEO.After a reader finishes reading an article, if they can immediately see highly relevant recommendations related to the current content, it will undoubtedly greatly increase their interest in continuing to explore the website.AnQi CMS understands this need and provides powerful and flexible features to help users easily achieve this goal.### AnqiCMS's "Related Documents" feature One of the core strengths of AnqiCMS lies in its powerful content management and template tag system

2025-11-09

How to display the detailed content page of articles or products?

In Anqi CMS, the display of article or product detailed content pages is the core link of website content operation.A well-designed, comprehensive detail page that can effectively convey content value and enhance user experience and search engine friendliness.Strong and flexible tool set provided by AnQi CMS, allowing us to easily achieve these goals. ### The Foundation of Content: Content Model and Template Files In Anqi CMS, all articles and products are unified as "content" (archive). They can exhibit different forms

2025-11-09

How to get and display all articles under a specific category?

In website content management, effectively organizing and displaying articles is the key to improving user experience and the clarity of the website structure.Strong and flexible template tag features are provided by AnQi CMS, allowing you to easily retrieve and display all articles under a specific category.Ensure content structure clarity: The foundation of backend category settings Before starting operations at the template level, we must first ensure that the content structure of the backend is clear and reasonable.The AnQi CMS category management feature is located under the "Content Management" module, where you can create and manage various article categories, such as "Company News"

2025-11-09

How to display a list of all independent web pages of the website?

In AnQiCMS, the independent pages of a website play a crucial role, usually carrying core information such as "About Us", "Contact Information", "Privacy Policy", etc. They are an indispensable part of building website trust and perfecting the information architecture.This article will introduce how to effectively manage and display these independent page lists in Anqi CMS. ### Understanding the 'Independent Page' in AnQi CMS In the context of AnQi CMS, what we refer to as the 'Independent Page' corresponds to the 'Single Page' feature in the system.These pages and articles

2025-11-09

How to retrieve and display detailed content of a specific independent page?

Our Anqi CMS provides great flexibility in content management, especially for pages that need to display independent, static information, such as "About UsThese are called "independent pages" or "single pages", their content is usually relatively fixed, but they also need to be independently displayed and have search engine friendly features.How can we efficiently retrieve and display the detailed content on these specific independent pages in AnQi CMS?

2025-11-09

How to display a list of all used tags (Tags) in the website?

In website operation, tags are an important tool for content organization and user discovery.A clear and complete list of tags can not only help users quickly find the content they are interested in, but also improve the website's SEO performance and guide search engines to better understand the structure of the website content.AnQi CMS provides powerful and flexible tag management and display functions, allowing you to easily display a list of all tags used on the website.### The display method of the site-wide tag list If you wish to establish a dedicated page on the website to showcase all used tags

2025-11-09

How to retrieve and display all articles associated with a specific tag?

AnQi CMS: Accurately locate and display the list of articles under specific tags In AnQi CMS, the Tag is a very practical feature that can help us classify and manage website content more finely, improve the efficiency of users discovering relevant content through keywords, and also greatly benefit the SEO performance of the website.By adding meaningful tags to articles, we can link together similar topics scattered across different categories, providing users with a more cohesive and in-depth reading experience.This article will delve into how to make use of the powerful template tag features of AnQi CMS

2025-11-09