How to use AnQi CMS template tags to get the document list under a specific category?

Calendar 👁️ 56

AnQiCMS (AnQiCMS) lays a solid foundation for the flexible display of website content with its powerful template functions.In website operation, we often encounter the need to display a list of documents under specific categories, such as news, product introductions, blog articles, etc.Mastering how to use template tags to achieve this function will greatly enhance the organization efficiency and user experience of the website content.

Core tags:archiveListusefulness

In Anqi CMS, the core tag to retrieve the document list under a specific category isarchiveList. It acts as a content filter, able to accurately extract the documents you need from the website content library based on your set conditions.archiveListThe basic usage structure of the tag is as follows:

{% archiveList 变量名称 with 参数1="值1" 参数2="值2" %}
    {# 在这里循环输出文档内容 #}
{% endarchiveList %}

Among them,变量名称Is the temporary name you customized for the document list you obtained, convenient for reference in the subsequent template code.

Key parameter parsing

In order toarchiveListThe tag precisely understands your intention, we need to use a series of parameters to refine the filtering conditions:

  • categoryIdThis is the core parameter of the specified category. You can specify the categories under which you want to retrieve documents by providing one or more category IDs.For example, if you want to get the documents under the article category with ID 1, you can write it like this:categoryId="1"If you need to retrieve documents from multiple categories with IDs 1, 2, 3, just separate the IDs with a comma:categoryId="1,2,3"It is worth noting that if your template is currently on a category page (such as the "Company News" category page),archiveListThe system usually intelligently identifies the current category ID, where you can omit itcategoryId. But if you want to explicitly not read the current category ID, or to get a category ID unrelated to the current page, you can set it tocategoryId="0".

  • moduleId: AnQi CMS supports various content models such as articles, products, etc. This parameter is used to specify which model's documents you want to retrieve. For example,moduleId="1"usually corresponds to the article model, whilemoduleId="2"May correspond to a product model. These model IDs can be viewed and managed in the "Content Management" -> "Content Model" on the AnQi CMS backend, specifying them clearly helps ensure that the correct type of content is obtained.

  • typeThis parameter determines the output method of the document list, the two most commonly used values are"list"and"page".

    • Whentype="list"then,archiveListIt will be based on the one you havelimitThe number of parameters set, output the document list directly without pagination processing. This is very suitable for displaying a small number of popular, latest, or recommended documents on the homepage, sidebar, or footer area of a website.
    • Whentype="page"then,archiveListIt will generate pagination data for the document list. This means that you can combinepaginationtags to provide users with a complete pagination browsing experience that includes “Previous page”, “Next page”, and page numbers.
  • limit: Used to control how many documents you want to display. For example,limit="10"it means 10 documents will be displayed.limitThe parameter also supports an “offset” mode, for example,limit="2,10"It indicates that the system will skip the first 2 documents (indexing starts from 0) and then retrieve the next 10 documents.This is very practical in certain specific content layout or personalized recommendation scenarios.

  • order: The document sorting method. You can choose different sorting rules according to your needs, such asorder="id desc"means sorting by document ID in descending order (usually representing the most recent release),order="views desc"representing in descending order of views (most popular), ororder="sort desc"(sorted by backend customization) etc.

  • flagIf you have set recommended attributes for the document in the background (such as "Top[h]", "Recommended[c]", "Slide[f]", etc.), you canflagParameters to filter documents with specific properties. For example,flag="c"Only documents marked as "Recommended" will be displayed.

Practical operation examples

To better understand the application of these parameters, let's look at several actual scenarios:

Scenario one: Display the latest 5 documents under the "Company News" category on the homepage

Assuming the 'Company News' category ID is 5, the article model ID is 1.

<div class="news-section">
    <h3>公司新闻</h3>
    <ul>
    {% archiveList latestNews with moduleId="1" categoryId="5" order="id desc" limit="5" %}
        {% for item in latestNews %}
        <li>
            <a href="{{ item.Link }}">
                <h4>{{ item.Title }}</h4>
                <p>{{ item.Description|truncatechars:80 }}</p> {# 截取描述前80个字符,增加易读性 #}
                <span>发布时间:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
            </a>
        </li>
        {% empty %} {# 如果没有文档,显示此内容 #}
        <li>暂无新闻动态。</li>
        {% endfor %}
    {% endarchiveList %}
    </ul>
</div>

Scenario two

Related articles

How to customize the layout and content of the document detail page in AnQi CMS?

In Anqi CMS, the custom display layout and content of the document detail page are crucial for realizing website personalization and meeting specific business needs.The ultimate form of website content, detail pages not only carry core information but also directly affect user experience and search engine optimization effects.The AnQi CMS offers a highly flexible template mechanism and rich data tags, allowing users to easily create unique document detail pages according to their own creativity.

2025-11-08

How to call and display the latest article list in AnQi CMS?

As a feature-rich and easy-to-use content management system, AnQi CMS provides great flexibility in content display.When you need to show your visitors the latest articles on the website, such as on the homepage, sidebar, or specific topic pages, Anqi CMS can help you easily achieve this.To implement the "Display the latest article list in Anqi CMS", the core lies in flexibly using its powerful template tag system, especially the `archiveList` tag.

2025-11-08

How can I obtain and display the links and titles of the previous/next document on the document detail page?

In website content operation, adding "Previous" and "Next" navigation to the document detail page is a common strategy to improve user experience, guide users to deeply browse, and optimize the internal links of the website.AnQiCMS is a content management system that fully considers these needs and provides intuitive and simple template tags, allowing you to easily achieve this function.### The advantage of AnQiCMS implementing the "Previous/Next" navigation AnQiCMS's template system is designed ingeniously, adopting syntax similar to the Django template engine, by

2025-11-08

How to implement sorting display of content in a document list by the latest, the hottest, and other methods?

When managing website content, how to effectively organize and display a list of documents so that it meets user habits and highlights the key points is a very critical link.AnQiCMS (AnQiCMS) provides flexible and powerful features that allow you to easily implement various sorting and filtering of document content, whether it is by the latest release, most popular, or other customized methods.In AnqiCMS, the flexible display of the document list is mainly realized through the powerful `archiveList` template tag.

2025-11-08

How to implement lazy loading display effect of images in AnQi CMS article content?

In website operation, the speed of image loading is crucial for user experience and Search Engine Optimization (SEO).Especially when an article contains a large number of images, loading all images at once will significantly increase page loading time, consume user traffic, and may cause users to leave prematurely.At this moment, the Lazy Load (Lazy Load) image technology can fully show its prowess.The core idea of lazy loading is to only start loading images when they are about to enter the user's visible area, rather than loading all of them at the initial page load.

2025-11-08

How to set and display the navigation menu (top/bottom) of the AnQi CMS website?

The website navigation is the key path for users to explore the website content, and it is also an important reference for search engines to understand the website structure.In AnQiCMS (AnQiCMS), you can flexibly set and manage the top and bottom navigation menus of the website to meet different design and functional requirements.This article will introduce how to configure the navigation menu in Anqi CMS backend, as well as how to display it in the website frontend template.## Part One: Back-end Configuration of Navigation Menu The navigation menu settings in AnQi CMS are concentrated in the "Back-end Settings" area of the back-end.

2025-11-08

How to configure and display SEO TDK information on the homepage of AnQi CMS?

In website operation, Search Engine Optimization (SEO) is the key to improving website visibility and attracting natural traffic.And TDK (Title, Description, Keywords) information, as the "business card" of website content on the search engine results page (SERP), its configuration rationality directly affects the user click-through rate and the search engine ranking performance.For users using AnQiCMS (AnQi CMS), the system is built with intuitive and powerful TDK configuration features, making homepage SEO optimization simple and efficient.###

2025-11-08

How to customize the URL static rules of AnQi CMS article pages to optimize SEO display?

In website operation, a clear and search engine-friendly URL address not only improves user experience but is also a key link in website SEO optimization.AnQiCMS (AnQiCMS) fully understands this and therefore provides a flexible and versatile custom static URL feature to help users easily create article page links that comply with SEO practices.### Overview of Anqi CMS's SEO-friendly URL capability SEO-friendly URL technology, as the name implies, is to make dynamic pages look like static pages with fixed and meaningful URLs

2025-11-08