How to efficiently display the latest list of articles released in Anqi CMS?

Calendar 👁️ 69

In Anqi CMS, efficiently displaying the latest published article list is the foundation of website content operation, which can help keep your website vibrant and allow visitors to obtain the latest information first.AnQi CMS provides flexible and powerful template tags, allowing you to easily achieve this goal.

Understand the Core:archiveListThe charm of tags

To display the latest list of published articles, we mainly rely on the built-in AnqicmsarchiveListTemplate tag. This tag is the core tool for obtaining the list of various documents (such as articles, products, etc.) on the website. It is feature-rich and can be customized according to your specific needs.

Basic usage: Display the latest articles

The most common requirement is to simply display a few of the latest articles published on the website. To achieve this, you need to use the template file.archiveListLabel, and cooperate with several key parameters:

  • type="list": Tell the system that you want to get a non-paginated list.
  • order="id desc": This is the key to specifying the sorting method.id descThis represents sorting documents by ID in descending order, as the ID of newly published articles is usually larger, which ensures that the latest articles are displayed at the top.
  • limit="5": Controls the number of articles displayed, for example, displaying the most recent 5 articles.

Here is a simple example, which will list the latest 5 article titles and links on your page:

{% archiveList latestArticles with type="list" order="id desc" limit="5" %}
    <ul>
    {% for item in latestArticles %}
        <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
    {% endfor %}
    </ul>
{% endarchiveList %}

Here, latestArticlesThis is the variable name you give to this list of data, you can name it according to your preference. ByforLooping through this variable will allow you to display the details of each article one by one, for exampleitem.Linkget the article link,item.TitleGet the article title.

Customize deeply: meet more 'latest' needs

Of Security CMSarchiveListTags are not just simple lists of the latest articles, but they can also meet your more detailed 'latest' content display needs.

Display latest articles by category

If your website has multiple categories and you want to display only the latest articles of a specific category on a specific category page or module on the homepage, you can usecategoryIdParameter.

For example, to display the latest 10 articles under the "News动态" category:

{% archiveList newsArticles with type="list" categoryId="您的新闻分类ID" order="id desc" limit="10" %}
    <h2>最新新闻</h2>
    <ul>
    {% for item in newsArticles %}
        <li><a href="{{ item.Link }}">{{ item.Title }}</a> - {{ stampToDate(item.CreatedTime, "2006-01-02") }}</li>
    {% endfor %}
    </ul>
{% endarchiveList %}

here,categoryIdThe value should be replaced with your actual category ID. If you are calling from the current category page and have not specifiedcategoryIdThe system will automatically retrieve the articles under the current category.

Filter the latest list of content of a specific type.

The AnqiCMS supports a flexible content model, you may have distinguished between the 'article' model and the 'product' model. If you only want to display the latest released products instead of all documents, you can usemoduleIdParameter.

For example, get the latest 3 products:

{% archiveList latestProducts with type="list" moduleId="您的产品模型ID" order="id desc" limit="3" %}
    <h3>最新产品推荐</h3>
    <ul>
    {% for item in latestProducts %}
        <li><a href="{{ item.Link }}"><img src="{{ item.Thumb }}" alt="{{ item.Title }}"> {{ item.Title }}</a></li>
    {% endfor %}
    </ul>
{% endarchiveList %}

Please replacemoduleIdReplace it with the actual ID of your product model.

Highlight the latest articles marked as "Recommended" or "Headline"

The Anqi CMS allows you to set recommended attributes for articles (such as headline [h], recommended [c], etc.). If you want to highlight these contents in the latest article list, you can useflagParameter.

For example, display the latest 5 'Top Stories' articles:

{% archiveList featuredNews with type="list" flag="h" order="id desc" limit="5" %}
    <div class="featured-articles">
        <h4>头条速递</h4>
        {% for item in featuredNews %}
            <p><a href="{{ item.Link }}">{{ item.Title }}</a></p>
        {% endfor %}
    </div>
{% endarchiveList %}

Hereflag="h"Ensure that only articles marked as 'Top Stories' are displayed.

Optimize display: date and pagination

Standardize the display of publication time

When displaying the latest articles, the publication time is a very important piece of information. The article time field in Anqi CMS (such asCreatedTimeStored in timestamp format. To format it as a readable date, you can usestampToDate.

For example, convert the timestampitem.CreatedTimeto the format "2023-10-26":

{{ stampToDate(item.CreatedTime, "2006-01-02") }}

Here"2006-01-02"Is the time formatting standard in Go language, representing year-month-day. You can adjust the format as needed, such as"2006年01月02日 15:04"displayed as "October 26, 2023 10:30".

Add pagination to long lists

If the latest article list is long, displaying all articles at once will affect page loading speed and user experience. At this time, you should combine the use ofarchiveListandpaginationtags to achieve pagination display.

First, inarchiveListsettype="page"And specifylimitParameters to control the number of articles displayed per page:

{% archiveList allLatestArticles with type="page" order="id desc" limit="10" %}
    <!-- 文章列表内容,与之前的for循环类似 -->
    {% for item in allLatestArticles %}
        <div class="article-item">
            <h3><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
            <p>发布时间:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</p>
        </div>
    {% endfor %}
{% endarchiveList %}

Following that, inarchiveListlabel's{% endarchiveList %}After that, usepaginationtags to generate pagination navigation:

<div class="pagination-nav">
    {% pagination pages with show="5" %}
        {% if pages.PrevPage %}<a href="{{ pages.PrevPage.Link }}">上一页</a>{% endif %}
        {% for pageItem in pages.Pages %}
            <a href="{{ pageItem.Link }}" class="{% if pageItem.IsCurrent %}active{% endif %}">{{ pageItem.Name }}</a>
        {% endfor %}
        {% if pages.NextPage %}<a href="{{ pages.NextPage.Link }}">下一页</a>{% endif %}
    {% endpagination %}
</div>

show="5"This means that up to 5 page number buttons are displayed. In this way, your latest article list can be presented to users in a more friendly manner.

Improve efficiency and user experience

Aqie CMS is developed based on the Go language and has a natural advantage in handling high concurrency and data requests. It is配合 its built-in static caching mechanism, even frequent callsarchiveListTags can also ensure the response speed of the website. When designing templates, it is reasonable to plan the page structure, and make use ofincludeAn auxiliary label reuse code snippet not only improves development efficiency, but also makes template code more tidy and convenient for subsequent maintenance.

By flexible applicationarchiveList/stampToDateandpaginationTags, you can display the latest published article list in an efficient and beautiful way according to the actual needs of the website, thereby enhancing the perception of the frequency of content updates on the website and increasing user stickiness.

Frequently Asked Questions (FAQ)

  1. Ask: I want to display the latest articles of different categories in different areas of the homepage, how should I operate?Answer: You can use the homepage template multiple timesarchiveListtags, passing through each callcategoryIdParameters specify different category IDs. For example, one list displays the latest 5 articles of 'News Center', and another list displays the latest 3 articles of 'Industry Dynamics', simply pass in differentcategoryIdJust do it.

  2. Ask: Why did I setorder="id desc"But the publication date of the latest article list does not always seem to be the most recent?Answer:order="id desc"It is indeed arranged in descending order by article ID, which usually coincides with the publication time sequence.Please note that AnQi CMS provides the "timed release" function.If an article is set to a future publish time, even if it gets a larger ID when created in the background, it will not be displayed on the front page before reaching the publish time.Once the publish time is reached, it will appear and may be at the top of the list due to a larger ID.Please check the actual release time setting of the article.

  3. Ask: I want to display the latest articles while also showing the thumbnails and summaries of each article in the list. How can I achieve this?Answer: InarchiveListofforIn the loop, you can accessitemmultiple fields of an object. For example,item.ThumbCan retrieve the thumbnail image address of the article (provided that the article has set a thumbnail image),item.DescriptionYou can get the article summary. Just insert these fields into your list HTML structure. For example:<img src="{{ item.Thumb }}" alt="{{ item.Title }}"> <p>{{ item.Description }}</p>.

Related articles

How to generate and manage a Sitemap to enhance the visibility of website content in search engines

For any website that hopes to stand out in search engines, Sitemap is an indispensable tool.It is like a detailed map of your website content, indicating all pages that can be crawled and indexed by search engine spiders (crawlers).In AnQi CMS, generating and managing a Sitemap is an efficient and user-friendly task that can significantly enhance the visibility of your website content.What is a Sitemap and why is it important?Sitemap, in short, is a website map.It is an XML file

2025-11-09

How can you use the content collection feature to quickly fill a large amount of content to be displayed?

Running a website, the most annoying thing is filling content.Whether it is a new site going online that needs to quickly accumulate a large amount of basic content, or an existing website that needs to maintain continuous updates to attract and retain users, manually writing or organizing content is a time-consuming and labor-intensive task.Today in content marketing and SEO optimization, how to efficiently and in bulk acquire and manage the content to be displayed has become a challenge for many operators.AnQiCMS (AnQiCMS) understands this pain point and its built-in content collection function is specifically designed to solve this problem.It is not simply copy and paste

2025-11-09

How does AnQiCMS's scheduled publication feature ensure that content is displayed accurately at the specified time?

## Precisely Control Content Release: How AnQiCMS's Scheduled Publishing Function Ensures Accurate Display at Specified Time Points In today's rapidly changing online world, the timeliness and consistency of content are crucial for the success of a website.In order to coordinate with marketing activities, respond to sudden hotspots, or simply to maintain the rhythm of daily updates, manually posting content is often inefficient and prone to errors.At this time, the time scheduling publishing function provided by AnQiCMS is particularly important, as it can act like a precise butler, ensuring that your content is accurately displayed to readers at any preset time point without error

2025-11-09

How to set up 301 redirect to avoid the display effect of page when the content URL changes?

## No worries about URL changes: Anqi CMS sets up 301 redirects easily, avoiding any impact on the page display effect URL changes are common in the operation of a website.It is necessary to adjust the website URL due to the need for optimizing content structure, integrating old information, and even changing domain names.However, if these changes are not handled properly, it is like sending a 'missing person' notice to an old address, visitors and search engines will encounter a 404 error page at the old link, which will seriously harm the user experience

2025-11-09

How to completely customize the content display layout of the article detail page?

In AnQi CMS, creating a unique and richly detailed article page is not difficult.This is not just a modification of the style, but also goes deep into every link of content structure, data retrieval, and front-end rendering, achieving true 'complete customization'.AnQi CMS provides us with great flexibility in content models and powerful template engines, enabling us to achieve this goal. ### Understanding the "skeleton" of the article detail page: template mechanism To customize the article detail page, you first need to understand the template mechanism of Anqi CMS.In Anqi CMS

2025-11-09

How to aggregate and display the content list of multiple article categories on a single page?

In Anqi CMS, implementing a feature to aggregate multiple article category content lists on a single page is a very practical requirement. It can help website administrators organize content efficiently and provide visitors with a more convenient browsing experience.This is commonly applied to the homepage, special pages, or aggregate pages of a website, where we can easily achieve the goal by skillfully using AnQiCMS template tags.### Core Concept: Tag Combination and Nested Loops AnQi CMS provides a flexible template tag system

2025-11-09

How to implement multilingual front-end display and switching of website content in AnQiCMS?

When building a website for global users, the display and switching of multilingual content are essential.AnQiCMS (AnQiCMS) understands the importance of this requirement and has integrated powerful multilingual support capabilities into the system design from the beginning, helping websites easily achieve internationalization of content. ### The Basics of Content Multilingual Management: Multi-Site Mode One of the core mechanisms for implementing multilingual display of website content in Anqi CMS is its flexible "Multi-Site Management" function.For a truly multilingual website

2025-11-09

How to configure pseudo-static URL rules to optimize the search engine display of website content?

In today's internet environment, the search engine display effect of website content is directly related to traffic and conversion.A clear and meaningful URL structure not only enhances user experience but is also an indispensable part of search engine optimization (SEO).AnQiCMS (AnQiCMS) understands this and therefore provides a powerful and flexible pseudo-static URL rule configuration function to help website managers easily optimize URL structure.Why configuring pseudo-static URL rules is crucial for the search engine display of website content?Before getting to know how to configure

2025-11-09