In website operation, the content display logic of category pages has an important impact on user experience and information architecture.We often encounter such needs: when there are subcategories under a category, prioritize displaying these subcategories to facilitate users in performing more detailed navigation; while if the category has no subcategories, directly display the article list under the category to avoid the page content being empty or the navigation hierarchy being too deep.AutoCMS (AutoCMS) provides flexible template tags, which can easily achieve this dynamic display effect.

Understanding the dynamic display logic of the category page

To implement the intelligent display of the classification 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, to guide users to more specific categories.
  2. If there are no subcategories:Show the list of articles contained in the current category, allowing users to directly browse the content.

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

English CMS implementation of key template tags for dynamic display

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

  1. categoryDetailTags:Used to obtain detailed information about the current category. We can use it to obtain the ID of the current category, which can then be passed 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 current category ID).
  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, used to retrieve its direct child categories. When used on the category page, if the current category ID is passed in, it can obtain all the child categories 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:During traversalcategoryListreturneditem, each category item includesId/Title/Linkand other information.
  3. archiveListTags:Used to get the list of articles (or any document model content).

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

4