How to combine the `archiveList` tag to filter and display the document list of a specific content model based on `moduleId`?

Calendar 👁️ 69

AnQiCMS Content Model Deep Guide: How to usearchiveListPrecisely filter document list

As a veteran in website operations for many years, I deeply understand the importance of a flexible and efficient content management system for a corporate website.AnQiCMS with its efficient architecture based on the Go language and highly customizable features, provides us with strong support in the content management field.Content modelThe feature is undoubtedly one of the highlights of AnQiCMS, allowing us to create and manage different types of content structures according to business needs, such as articles, products, cases, news, events, and so on.

Today, let's delve deeply into a very commonly used and powerful template tag in AnQiCMS -archiveListand focus on how to combinemoduleIdParameter, realize accurate filtering and display of document lists for specific content models.This can not only make your website content organized, but also provide users with a clearer and more targeted browsing experience.

Flexible content model: the cornerstone of refined management

In AnQiCMS, the content model is the core that defines the content type and its field structure.The system is built-in with "Article Model" and "Product Model", but the real power lies in being able to create an infinite number of custom models according to your actual business needs.For example, if you run a real estate website, you can create a 'listing model'; if it is a food blog, then you can create a 'recipe model'.moduleId.

ThismoduleIdIt is like the 'ID number' of the content world. When you publish an 'article', it is endowed with the article model'smoduleId; When releasing a 'product', it also has a product model.moduleId. It is this small onemoduleId, allowing us to accurately retrieve the information we want from the ocean-like content.

archiveListLabel: core driving of content display

archiveListIt is one of the most commonly used tags in the AnQiCMS template, responsible for retrieving and displaying a list of documents (i.e., all the content we create). Whether it's the latest dynamic on the homepage, the popular recommendations in the sidebar, or the detailed list on the category page, archiveListThey all play a crucial role.

Its basic usage is to iterate over the content, and extract the attributes of each content for display. To make this label 'smart', it can identify and filter content of different models.moduleIdParameters are particularly important.

Hand in handmoduleId: Filter your content list accurately.

When we need to display documents under a specific content model on a page or in a certain area of a website,moduleIdthe parameter is our first choice. By using inarchiveListExplicitly specify in the tagmoduleIdThe system can accurately filter out the document list belonging to the content model.

For example, suppose your "article model" ismoduleIdIs1while the "product model" ismoduleIdIs2You need to use two separate ones to display the latest article list in one area of the homepage and the recommended product list in another area.archiveListLabel, and throughmoduleIdto differentiate.

{# 获取文章模型的文档列表,假设文章模型的 moduleId 为 1 #}
{% archiveList latestArticles with moduleId="1" type="list" limit="5" order="id desc" %}
    {% for item in latestArticles %}
        <div class="news-item">
            <a href="{{ item.Link }}">
                <h4>{{ item.Title }}</h4>
                <p>{{ item.Description|truncatechars:100 }}</p> {# 截取描述,保持简洁 #}
                <span>发布日期:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
            </a>
        </div>
    {% empty %}
        <p>暂无最新文章。</p>
    {% endfor %}
{% endarchiveList %}

{# 获取产品模型的文档列表,假设产品模型的 moduleId 为 2 #}
{% archiveList featuredProducts with moduleId="2" type="list" limit="3" order="views desc" %}
    {% for item in featuredProducts %}
        <div class="product-card">
            <a href="{{ item.Link }}">
                {% if item.Thumb %}
                    <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
                {% endif %}
                <h5>{{ item.Title }}</h5>
                <p>浏览量:{{ item.Views }}</p>
            </a>
        </div>
    {% empty %}
        <p>暂无推荐产品。</p>
    {% endfor %}
{% endarchiveList %}

In the above example, we clearly sawmoduleId="1"andmoduleId="2"how twoarchiveListlabels were pulled apart, so that they are only responsible for displaying the documents under their respective content models.

exceptmoduleIdYou can also combine other parameters to further optimize your content list:

  • type: List type
    • type="list"Used to get a fixed number of lists, for example, the "Latest Articles" block on the homepage, which only displays the first 5.
    • type="page": Used for paginated lists, such as article list pages or product display pages, in conjunction withpaginationlabel usage
  • limit: Show the number
    • Control the number of documents returned in the list, such aslimit="10"Means to retrieve 10 documents.
  • order: Sorting method
    • order="id desc": Sort by document ID in reverse, usually used to display the latest released documents.
    • order="views desc": Sort by views in reverse, suitable for hot rankings and others.
    • order="sort desc"Custom sorting on the backend is provided, offering operational flexibility.
  • categoryIdCategory ID
    • Under a specific model, you can further proceed through.categoryIdFilter documents that belong to a certain category. For example,moduleId="1" categoryId="10"Only get the articles under the "Article Model" and with category ID 10.

Practice exercise: Build a list of multi-model content.

Let us go through a more complete example to show how to use in the AnQiCMS template,archiveListandmoduleIdParameter, elegantly displaying a list of documents for different content models.Assuming we have a homepage for a website that needs to display the 'Latest News' and 'Featured Services' sections.moduleId=1), the special service belongs to the 'Service Model'(moduleId=3This is a custom model)

`twig

{# 最新新闻区 - 假设新闻对应文章模型 moduleId 为 1 #}
<section class="latest-news">
    <h2>最新新闻</h2>
    <div class="news-list">
        {% archiveList newsItems with moduleId="1" type="list" limit="4" order="id desc" %}
            {% for item in newsItems %}
                <article class="news-card">
                    {% if item.Thumb %}
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="news-thumbnail">
                    {% endif %}
                    <div class="news-content">
                        <h3><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
                        <p>{{ item.Description|truncatechars:120 }}</p>
                        <time datetime="{{ stampToDate(item.CreatedTime, "2006-01-02T15:04:05") }}">
                            {{ stampToDate(item.CreatedTime, "2006年01月02日") }}
                        </time>
                        <span class="news-views">浏览:{{ item.Views }}</span>
                    </div>
                </article>
            {% empty %}
                <p>目前还没有新闻发布,敬请期待!</p>
            {% endfor %}
        {% endarchiveList %}
    </div>
</section>

<hr>

{# 特色服务区 - 假设服务模型 moduleId 为 3 #}

Related articles

The `moduleDetail` tag is available on non-model related pages (such as the homepage)? How to safely obtain and use model information?

AnQiCMS (AnQiCMS) provides great convenience for website operators with its flexible content model and powerful template tag system.However, in practice, we often encounter a question: whether a tag like `moduleDetail`, which is usually used to obtain information about a specific content model, is still available on pages such as the homepage of a website that is not related to the model.How can it be used safely and effectively to obtain the required model information?As an experienced website operations expert, I will take you deep into this topic.

2025-11-07

I want to display a specific icon or style in the template based on the content model's ID, what information can the `moduleDetail` tag provide to assist in the implementation?

The secret manual of AnQi CMS template customization: Skillfully use the `moduleDetail` tag to make different content models shine with unique charm In today's content-driven digital world, the appeal of a website does not only come from the quality of its content, but also from the exquisite form of its presentation and the smooth user experience.An enterprise CMS knows this, it endows operators with high flexibility with its powerful content model features, allowing them to create diversified content structures such as articles, products, events, etc. according to different business needs.

2025-11-07

The `moduleDetail` tag retrieves the model link (`Link`) - is it an absolute path or a relative path, and does it support customization?

## AanQi CMS `moduleDetail` tag: Is the model link path absolute or relative?The comprehensive analysis of the custom mystery As an experienced website operations expert, I am well aware that the subtle details of content presentation in every CMS system may have a profound impact on the website's SEO performance and user experience.AnQiCMS (AnQiCMS) leverages its efficient Go language genetics and enterprise-level positioning, also showing its unique strengths in URL structure management.Today, let's delve deeply into a problem that often arises in template development and content operations

2025-11-07

How to use the `moduleDetail` tag to dynamically display different content models' SEO keywords (`Keywords`) and descriptions (`Description`) in the template?

In the powerful ecosystem of AnQi CMS, the flexible content model is one of its core advantages, granting us the ability to build diverse content forms according to business needs.As an expert who has been deeply involved in website operations for many years, I know that no matter how rich and colorful the content is, its value will be greatly discounted if it cannot be efficiently identified and accurately presented to the target users by search engines.That is the foundation of all this, which is excellent SEO optimization. Anqi CMS provides many advanced tools in the field of SEO, from static rules to Sitemap generation, to keyword library management

2025-11-07

When a content model has custom fields (such as `author`), how can these model-specific custom fields be called in the `archiveDetail` tag?

Unlock the charm of AnQi CMS content model custom fields: advanced application of `archiveDetail` tag As a senior website operations expert, I fully understand the importance of a flexible content management system in improving operational efficiency and achieving personalized content display.AnQiCMS (AnQiCMS) excels in this aspect with its efficient architecture based on the Go language and excellent customizability.

2025-11-07

What is the collaboration or difference between the `archiveParams` tag and the `moduleDetail` tag in obtaining custom field information of the content model?

Today, with the increasing diversity of digital content, a flexible content management system (CMS) is undoubtedly the key to improving efficiency and achieving personalized display for enterprises and self-media operators.AnQiCMS (AnQiCMS) with its powerful content model function enables users to deeply customize the content structure according to their own business needs.However, when we delve into the template level, trying to retrieve this customized data, we may encounter some questions: `archiveParams` tag and `moduleDetail` tag

2025-11-07

Can I define different types of 'recommendation attributes' for different content models (such as 'top news' for article models and 'new product' for product models)?

As an experienced website operations expert, I know that accurately recommending different types of content in content management is the key to improving user experience and operational efficiency.AnQi CMS, with its flexible content model design, indeed provides us with powerful content organization capabilities.And regarding the differentiated definition of 'recommended attributes', this embodies some exquisite operational strategies and technical implementation methods, which are worthy of in-depth exploration.### AnQi CMS: The Flexible Application of Content Model and "Recommended Attributes" Many operators will have a question when they first contact AnQi CMS

2025-11-07

How to dynamically judge whether a custom field of a content model is set as required in the template?

Anqi CMS is an efficient and flexible content management system, its powerful content model customization function indeed brings great convenience to enterprises and operators.In daily content operation, we often add various custom fields for different content models (such as articles, products, events, etc.) according to business needs.These fields are some optional, some are required to be filled in, that is, 'mandatory items'.

2025-11-07