Can the `moduleId` parameter of the `categoryList` tag specify multiple model IDs for a union query?

Calendar 👁️ 60

As an experienced website operation expert, I have a deep understanding of the powerful functions and flexible template system of AnQiCMS (AnQiCMS).In daily content operation, we often encounter the need to aggregate and display different types of content.Today, let's delve into it in depthcategoryListin the tagmoduleIdThe use of parameters, especially whether it can specify multiple model IDs for joint queries at the same time.

Deep understandingcategoryListwith the tag andmoduleIdParameter

in the AnQi CMS template world,categoryListLabels are undoubtedly one of the core tools for content aggregation and display.It allows us to conveniently obtain and display the classification structure of the website, whether it is article classification, product classification, or other customized content model classifications, they can be flexibly retrieved through it.moduleIdThe parameter is exactlycategoryListThe core of the label, which is mainly used to specify which content model's category list you want to get.

One of the highlights of AnQi CMS is its flexible content model design.This means you can create various content types based on business needs, such as an "article model" for publishing news blogs, a "product model" for displaying products, and even create "case models", "service models", and so on.Each category created will be bound to a specific content model.moduleIdThe role of the parameter is to accurately tellcategoryListLabel: “I need to retrieve the article model (“moduleId=1All categories under or "The product model I need is ("moduleId=2Categories under ("

moduleIdCan the parameter achieve multi-model joint query?

Now, let's face the core issue:categoryListlabel'smoduleIdCan the parameter specify multiple model IDs at the same time, for example?moduleId="1,2"ormoduleId="1|2"Thus, can we achieve joint queries or mixed displays of different content model classifications?

Based on a deep understanding of the AnQi CMS features and template tag syntax, my answer is:categoryListlabel'smoduleIdParameterCannot directly use multiple model IDs (for example, separated by commas or pipes) to perform a union query across different model categories.

This is mainly because the AnQi CMS is designed in such a way that each category is closely associated with only one content model.moduleIdThe parameter is intended to explicitly specify the classification under "which" content model, rather than "which" models. The document mentionedmoduleId="1|2|3"It is more like an illustrative expression of the parameter "possible values", hinting that it can accept model ID 1, 2 or 3, but does not indicate that these three IDs can be input simultaneously for a joint query. In actual template parsing,moduleIdExpect a single integer value representing a specific content model ID.

How to implement an aggregated display of multi-model classification?

AlthoughmoduleIdThe parameter itself does not support joint queries of multiple models, but this does not mean that we cannot flexibly aggregate and display data from different models in the template. Anqi CMS provides enough flexibility to meet such needs, and there are mainly the following strategies:

  1. Call in stagescategoryListTagThis is the most direct and clearest implementation. If you need to display categories from different models in different areas of the page or according to different logic, you can use it multiple times.categoryListLabel, passed in each callmoduleId.

    For example, you may want to list all article categories first in a navigation menu, followed by all product categories:

    <nav class="main-navigation">
        <h4>文章分类</h4>
        <ul>
            {% categoryList articleCategories with moduleId="1" parentId="0" %}
                {% for item in articleCategories %}
                    <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
                {% endfor %}
            {% endcategoryList %}
        </ul>
    
        <h4>产品分类</h4>
        <ul>
            {% categoryList productCategories with moduleId="2" parentId="0" %}
                {% for item in productCategories %}
                    <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
                {% endfor %}
            {% endcategoryList %}
        </ul>
    </nav>
    

    The advantages of this method are clear logic, easy to maintain, each group of classification data comes from its respective model, and the responsibilities are clear.

  2. Utilizeall=trueParameters retrieve all categories and perform template-level filtering.: If you need to getallall categories under the content model (not limited to a specific model),categoryListprovided a more direct parameter:all=true. When you useall=truethen,categoryListwill ignoremoduleIdparameter (if specified)moduleId, thenall=trueIt will only retrieve all categories under the specified model, not all models. You can do this through the template.item.ModuleIdProperties further classify or filter these categories.

    <nav class="all-categories-navigation">
        <ul>
            {% categoryList allCategories with all=true parentId="0" %}
                {% for item in allCategories %}
                    <li>
                        {% if item.ModuleId == 1 %}
                            <span class="category-type">[文章]</span>
                        {% elseif item.ModuleId == 2 %}
                            <span class="category-type">[产品]</span>
                        {% endif %}
                        <a href="{{ item.Link }}">{{ item.Title }}</a>
                    </li>
                {% endfor %}
            {% endcategoryList %}
        </ul>
    </nav>
    

    This method is suitable for scenarios where it is necessary to display all categories mixed in a list and can be distinguished through conditional judgment on the front end.Please note that if the amount of data is very large, too many template filters may cause a slight impact on the front-end rendering performance.

Considerations in practice

The design of AnQi CMS actually encourages us to keep the template logic clear: eachcategoryListCalls are all targeted at a clear content model, making the intention of data acquisition more intuitive and convenient for subsequent maintenance and debugging.When your content structure becomes complex, this clarity greatly reduces the probability of errors.

Frequently Asked Questions (FAQ)

  1. Q: How can I display both the "Company News" category (from the article model) and the "Latest Products" category (from the product model) in a navigation bar?A: You should call `category` twice

Related articles

How to implement the display of the 'sibling categories' of the current category in `categoryList`, instead of the subcategories?

AnQi CMS is an efficient and customizable content management system, playing an important role in website operations.Its template system is powerful and flexible, allowing operators to finely control the display of content according to actual needs.Today, let's delve into a common issue in actual operation that beginners may find confusing: how to cleverly display 'sibling categories of the current category' in the `categoryList` tag, rather than its subcategories.It is of great significance to display the brother category list in terms of content organization and user experience.

2025-11-06

`categoryList`Does it support filtering or displaying based on custom fields by category?

HelloAs an experienced website operations expert, I know the importance of a flexible content management system for efficient operations.AnQiCMS stands out among many CMS systems with its excellent customizability, especially in content modeling and category management, providing great convenience.However, many operators may wonder a question when using the `categoryList` tag: does it support filtering or displaying based on custom fields of categories?

2025-11-06

How to display different content in the `categoryList` loop based on the different `moduleId`?

As a senior website operations expert, I fully understand that the flexibility of content presentation is crucial for user experience and operational efficiency.AnQiCMS (AnQiCMS) relies on its powerful template engine and content model mechanism to provide us with a powerful tool for achieving this flexibility.Today, let's delve into a very practical scenario: how to intelligently display distinctive content according to different `moduleId` in the `categoryList` loop.

2025-11-06

Does the `categoryList` return category link automatically adapt to the pseudo-static rule set in the background?

As an experienced website operations expert, I know the importance of URL structure for website SEO and user experience.AnQiCMS (AnQiCMS) fully considered this from the beginning, its static and SEO optimization features are one of its core highlights.Today, let's delve into a common concern of operators: When using the AnQiCMS `categoryList` tag to call category links, will these links automatically adapt to the pseudo-static rules set in the background?

2025-11-06

How to quickly view all available fields and values of the `categoryList` returned item object during template debugging?

During the development and debugging of Anqi CMS templates, we often need to gain a deep understanding of the data structure returned by template tags in order to control the display of page content more accurately.Especially like the `categoryList` such list tags, it will loop to output multiple `item` objects, each carrying rich data.How can we quickly and comprehensively view the available fields and their corresponding values in the `item` object returned by `categoryList` when debugging?

2025-11-06

`categoryList`How to use the `empty` tag block when no categories are found, and how to customize prompt information?

As an experienced website operations expert, I know that every detail in the presentation of website content may affect the user experience and the professional image of the website.Especially in the scenario where data is "missing", how to avoid making the page look stiff, blank, or even confusing to users is a task that requires careful design.Today, let's delve into how to skillfully use the `empty` tag block to customize friendly prompt information when the `categoryList` tag in AnQi CMS does not find any category data.

2025-11-06

Is the `categoryList` tag returning categorized data real-time from the database or does it have an in-built caching mechanism?

In the daily operation of website management, the speed and efficiency of data access are core elements of user experience and search engine optimization.For systems like AnQiCMS (AnQiCMS) that are dedicated to providing efficient and customizable content management solutions, whether the internal data processing mechanism, especially tags like `categoryList` that are frequently called, always directly query the database or have an intelligent caching mechanism, is a focus of many operators.

2025-11-06

How to limit the display quantity of each subcategory level when nesting multi-level categories?

AnQiCMS is an efficient and flexible content management system that excels in building structured content, especially its multi-level classification feature, which helps us clearly organize website content.However, when displaying multi-level category nesting, we often encounter a challenge: how to elegantly control the display quantity of each sub-category level to avoid the page being too long or the load being too heavy?As an experienced website operation expert, I am well aware of the importance of this requirement. Today, I will delve into the exquisite way to achieve this goal in AnQiCMS with everyone.

2025-11-06