How to get the list of the latest published or articles/products under a specified category?

Calendar 👁️ 59

As an experienced AnQiCMS (AnQiCMS) website operations manager, I fully understand the importance of content presentation for website user experience and content marketing effectiveness.AnQi CMS provides a powerful and flexible template tag system, which allows us to easily obtain and display various types of articles and product lists, whether it is the latest content update or a special theme display under a specific category, all can be achieved through simple configuration.

Understanding the content model of Anqi CMS

Before starting to retrieve the content list, understanding the content model of Anqi CMS is fundamental.The AnQi CMS supports custom content models, but the default usually includes the 'Article Model' and the 'Product Model'.moduleIdFor example, the article model usually corresponds tomoduleIdIt could be1, the product model could be2. When calling the content list in our template, specify the correctmoduleIdIt is crucial, it ensures that we get the expected type of content.

Get the latest released or updated articles/products list

Displaying the latest updates on the website is an effective way to attract users and enhance activity. In Anqi CMS, to obtain the latest published articles or product lists, it mainly relies onarchiveListTemplate tag. This tag provides rich parameters for filtering, sorting, and limiting the display of content.

To obtain the latest content, we usually use the content ID for reverse sorting, as the ID is usually incremented, representing the order of content publication. By settingorder="id desc"The system will sort the content by content ID in descending order, that is, the latest released content will be at the top. At the same time,limitThe parameter can control how many items you want to display.

For example, to display the latest 5 news articles (assuming the article modelmoduleIdWith1), you can write the template code like this:

{# 获取最新发布的5篇新闻文章 #}
{% archiveList latestNews with moduleId="1" order="id desc" limit="5" %}
    {% for item in latestNews %}
    <div class="news-item">
        <h3><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
        <p>{{ item.Description|truncatechars:100 }}</p> {# 截取描述前100个字符 #}
        <span class="publish-date">发布日期: {{ stampToDate(item.CreatedTime, "2006年01月02日") }}</span>
    </div>
    {% endfor %}
{% endarchiveList %}

In this code block,latestNewsis the custom variable name you use to store the list of content queried.moduleId="1"We clarified that we need to obtain the article.order="id desc"We ensured that the content is sorted by the latest release.limit="5"It limited the display to only 5 items.stampToDateThe tags help us format the timestamp into a readable date.

Get the list of articles/products under a specified category

Create a content list for a specific topic or product series, which is the key to building a clear website structure and guiding user browsing.archiveListThe label can also perform this task exceptionally well, its core lies incategoryIdParameter.

You can use it tocategoryIdSpecify an ID for one or more categories to get the content under them. If multiple category IDs are specified, they must be separated by commas. By default,archiveListIt will include the content of the specified category and all its subcategories. If you only want to get the content of the current category (excluding its subcategories), you can set it additionallychild="false".

For example, to display “Product Category A” (assuming itscategoryIdWith10all products under it (assuming the product model ismoduleIdWith2), you can write it like this:

{# 获取“产品分类A”下最新的8个产品 #}
{% archiveList categoryProducts with moduleId="2" categoryId="10" order="id desc" limit="8" %}
    {% for item in categoryProducts %}
    <div class="product-card">
        <a href="{{ item.Link }}">
            <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
            <h3>{{ item.Title }}</h3>
            <p class="price">¥ {{ item.Price }}</p>
        </a>
    </div>
    {% endfor %}
{% endarchiveList %}

If you want to get the “Solution” (categoryIdWith12)and "Industry Cases"(categoryIdWith15)articles under these two categories, and only include the content of these two categories themselves, not the subcategories, the code will be like this:

{# 获取“解决方案”和“行业案例”分类下,不含子分类的文章 #}
{% archiveList caseStudies with moduleId="1" categoryId="12,15" child="false" limit="10" %}
    {% for item in caseStudies %}
    <div class="study-item">
        <h4><a href="{{ item.Link }}">{{ item.Title }}</a></h4>
        <p>{{ item.Description|truncatechars:150 }}</p>
    </div>
    {% endfor %}
{% endarchiveList %}

Display a large amount of content combined with pagination

When there is a large amount of content under a category, in order to avoid the page being too long and slow to load, we usually display it with pagination.archiveListTag by settingtype="page"Parameters, can automatically handle pagination logic. After that, you can usepaginationTag to render pagination navigation links.

”`twig {# Fetch all articles under the “Blog” category, display 10 per page, and enable pagination #} {% archiveList blogPosts with moduleId=“1” categoryId=“20” type=“page” limit=“10” %}

{% for item in blogPosts %}
<article class="blog-post">
    <h2><a href="{{ item.Link }}">{{ item.Title }}</a></h2>
    <p class="post-meta">发布于 {{ stampToDate(item.CreatedTime, "2006-01-02") }}</p>
    <div class="post-summary">{{ item.Description|safe }}</div>
    <a href="{{ item

Related articles

How to get and display the title, content, and link of a specific single-page?

As an experienced CMS website operation person, I know that content is the soul of the website, and how to efficiently and accurately display content is a crucial link in our daily work.In Anqi CMS, a single page usually carries the core information of the company introduction, contact information, service description, etc., and its content often needs to be specifically retrieved and displayed in various corners of the website.Today, let's discuss in detail how to obtain and display the title, content, and link of a specific single page in Anqi CMS.

2025-11-06

How to get the list of all single-page lists of a website?

As an experienced CMS website operation personnel of an enterprise, I know the importance of acquiring and managing website content, especially for single pages carrying core information such as 'About Us', 'Contact Information', or 'Terms of Service'.In AnQi CMS, the system provides an efficient and flexible way to obtain the list of these single pages, so that we can integrate them into website navigation, site map, or other display locations.

2025-11-06

How to retrieve detailed information for a specified category, such as the category name, description, and link?

As an experienced website content expert in AnQiCMS (AnQiCMS) operation, I fully understand the importance of classification information in building website structure and improving user experience.The Anqi CMS, with its intuitive and powerful template tag system, makes it exceptionally easy to obtain and display detailed information about categories.In order to optimize navigation, enrich page content, or improve SEO effect, accurately obtaining the category name, description, and link is an indispensable part of our daily operation.

2025-11-06

How to get the classification list under a specific content model (such as articles, products)?

As an experienced CMS website operation personnel for Anqi, I know the importance of content organization and user experience for the success of the website.Accurately display content categories, not only can help users quickly find the information they are interested in, but also improve the overall SEO performance of the website.Today, we will delve into how to obtain the category list under specific content models (such as articles, products) in AnQiCMS, which is crucial for building clear website navigation, content aggregation modules, and special pages.

2025-11-06

How to display the title, content, images, and other detailed information of the current content on an article or product detail page?

As a senior security CMS website operator, I know that the content detail page is a core component of the website, carrying the important mission of displaying key information such as products and articles to users.A well-designed, comprehensive detail page that not only effectively conveys content value but also enhances user experience and SEO performance.Strong and flexible template tags provided by Anqi CMS, allowing us to easily control the display of each item on the page.

2025-11-06

How can you easily obtain and display the link and title of the previous and next articles on the article detail page?

As an experienced website operator familiar with AnQiCMS, I fully understand the importance of effectively guiding users to browse and discover more content in content management.The navigation of the previous/next article on the article detail page not only can significantly improve user experience and prolong the time users stay on the site, but also helps to optimize the internal link structure of the website, which is very beneficial for SEO.I will elaborate in detail on how to conveniently and quickly obtain and display the links and titles of the previous and next articles on the article detail page of AnQiCMS.--- ###

2025-11-06

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

As an experienced security CMS website operator, I fully understand the importance of high-quality content and refined operation for user retention and website SEO.Display related recommended articles on the article detail page, which can not only effectively extend the user's time on the site and reduce the bounce rate, but also optimize through internal links, improve the overall weight of the website, and is an indispensable part of content operation.Below, I will give a detailed introduction on how to implement this feature in Anqi CMS.

2025-11-06

How to retrieve the custom field parameters defined in the content model and filter and display them?

As an experienced CMS website operation person in an enterprise, I know how important the custom field function of the content model is for building rich and personalized website content.It can not only help us organize information flexibly, but also provide users with more accurate filtering and display experience.I will explain in detail how to obtain the custom field parameters of the content model definition in Anqi CMS and perform effective filtering and display. ### Create and manage custom content model fields Firstly, all functions are based on the configuration in the background.In AnQi CMS

2025-11-06