How to get and display the list of articles under a specified category in AnQiCMS?

Calendar 👁️ 62

It is a very common requirement in website content operation to retrieve and display a list of articles under a specified category in AnQiCMS.Whether you want to display the latest articles of a specific category on the homepage or aggregate all content of a special topic on an independent page, AnQiCMS' powerful template tag system can help you achieve it easily.

AnQiCMS's template engine syntax is similar to Django, using concise and clear tags and variables, you can directly call backend data in HTML templates. This article will guide you on how to make use ofarchiveListLabel, accurately and efficiently implement the display of the article list.

Step 1: Clarify which category of articles you want to display.

First, you need to know the identifier information of the target category. This usually has two ways:

  1. Category ID:This is the most direct way. Log in to your AnQiCMS backend, go to "Content Management" -> "Document Categories".Here, you can find all the categories created and their corresponding numeric ID.For example, the 'Company News' category may correspond to ID 1, and the 'Industry Dynamics' may correspond to ID 2.Write down the category ID you need to use.
  2. Category URL alias (token):If your category is set to custom URL alias, you can also use this alias to specify the category. This will be very convenient in certain dynamic scenarios.

Second step: usearchiveListTags retrieve article data

archiveListIt is a powerful template tag provided by AnQiCMS, specifically used for retrieving article lists. Its basic structure is{% archiveList 变量名 with 参数列表 %}, and ends with:{% endarchiveList %}End. InwithAfter the keyword, you can pass a series of parameters to accurately control which articles to retrieve.

The following are common parameters used when retrieving a list of articles for a specified category.

  • categoryId:This is a key parameter used to specify which category of articles to retrieve. You can pass a single category ID, such ascategoryId="1"If you need to get articles of multiple categories, you can separate them with commas, for examplecategoryId="1,3,5".
  • moduleId:AnQiCMS supports various content models (such as articles, products, etc).moduleIdSpecify which type of model article to retrieve. Typically, the article model ID is 1, and the product model ID is 2.If you are unsure, you can check it in the "Content Management" -> "Content Model" in the background.
  • type:This parameter determines the type of the list.
    • type="list": Used to get a fixed number of article lists without pagination features. Often used in the homepage, sidebar, and other locations.
    • type="page"Used to generate a paginated list of articles. It is used when you need to display a large number of articles on a category list page, and it is combined withpaginationlabel usage
  • limit:cooperatetype="list"Use, to limit the number of articles displayed. For example,limit="5"Only the latest 5 articles will be displayed. If you want to start from the Nth article, you can set it like this:limit="2,5"Starting from the second article, displaying 5 articles.
  • order:Define the sorting method of the articles. Common values include:
    • order="id desc":Sort by article ID in descending order (usually meaning the most recently published articles are at the top).
    • order="views desc":Sort by article views in descending order (popular articles are at the top).
    • order="sort desc": Arrange in descending order according to the sorting value set in the background (article order can be manually adjusted).
  • child:Whether the article includes subcategory articles.child="true"The default setting includes articles of the specified category and all its subcategories;child="false"It only includes the direct articles of the specified category itself.
  • flag:Filtered based on the recommended attributes of the articles. For example,flag="c"Get recommended articles,flag="h"Get the headline article.

Step three: Traverse and display the article details.

archiveListThe tag will return an array of article objects, you need to use{% for ... %}Loop to traverse these articles and display their details one by one.

Within the loop, each article object usually has a default variable name (for example, in the example, if you define it asarticlesthen the variable inside the loop body isarticle)。ThisarticleThe variable includes various fields of the article, you can directly pass through{{ article.字段名 }}Call in the form.

Common article fields include:

  • {{ article.Title }}: Article title
  • {{ article.Link }}: Article link
  • {{ article.Description }}: Article Summary
  • {{ article.Thumb }}: Article thumbnail address
  • {{ article.Logo }}: Article cover first image address
  • {{ article.CreatedTime }}: Article publish time (this is a timestamp, usually need to bestampToDateformatted with tags)
  • {{ article.Views }}: Article views
  • {{ article.CategoryId }}: Article Category ID

**Tip for Time Formatting

Related articles

How to implement pagination display of the article list in AnQiCMS?

In AnQiCMS, the pagination display of the article list is a very common and important function in content operation.It not only makes it easier for visitors to browse a large amount of content, improve user experience, but also has an indispensable role in search engine optimization (SEO), which can help search engines better crawl and index website content.AnQiCMS as an efficient and customizable content management system took this into full consideration from the beginning, therefore the pagination function of the article list is very intuitive and flexible.This is mainly due to its powerful template tag system

2025-11-08

How to use AnQiCMS content model to customize fields and display them on the front end?

In website operation, we often encounter such situations: the standard 'article' or 'product' content type cannot fully meet our unique business needs.For example, you may need to post "real estate information", which requires special fields such as "house type", "area", "orientation", etc.Or you are running a "recruitment platform" and need "job title", "location", "salary range", and "skills required" and so on.At this moment, the flexible content model and custom field function of AnQiCMS are particularly important, as they can help us create a content structure that perfectly fits the business

2025-11-08

How to customize the URL structure of the article detail page in AnQiCMS for optimized display?

In website operation, a clear and meaningful URL structure not only helps search engines better understand and capture your content, but also significantly improves the browsing experience of users.AnQiCMS knows this and therefore provides flexible and powerful features that allow you to easily customize the URL structure of the article detail page. Let's take a deeper look at how AnQiCMS can help you achieve this goal, creating a more advantageous URL for your website.Why is it important to customize URL structure?Before delving into the features of AnQiCMS

2025-11-08

How to display article title and content in AnQiCMS template?

In Anqi CMS, whether it is to display the detailed content of a single article or present the article title and summary on the list page, it is all due to its flexible and easy-to-understand template tag system.AnQiCMS uses a syntax similar to the Django template engine, making content calls intuitive and efficient.

2025-11-08

How to set the TDK (Title, Description, Keywords) of the AnQiCMS homepage to affect search results display?

In website operation, making your website stand out in search engines is a key step to gain traffic.While the "front door" of a website - the homepage, its display effect in search results is often determined by TDK (Title, Description, Keywords).AnQiCMS is a system focused on enterprise-level content management, which provides intuitive and powerful settings to easily control the homepage's image in the eyes of search engines.--- ### What is TDK and why is it so important

2025-11-08

How to display website logo and copyright information in AnQiCMS template?

When building and operating a website, the website's logo and copyright information are an important component of brand image, building user trust, and fulfilling legal statements.For AnQiCMS users, managing and displaying this information is very intuitive and flexible. ### In AnQiCMS backend, set the website logo and copyright information AnQiCMS centralizes the global configuration of the website, allowing you to easily set various basic information.To set the website logo and copyright, you need to go to the 'Global Function Settings' page in the backend.1.

2025-11-08

How to display links to the previous and next articles on the AnQiCMS article detail page?

When visitors browse articles on a website, they often hope to be able to jump to related content conveniently, especially the previous or next one.This design not only improves the user experience, but also has a positive impact on the internal link structure of the website and search engine optimization.AnQiCMS fully considered such user needs, built in simple and efficient template tags, helping us easily implement the previous and next article link function on the article detail page.

2025-11-08

How to display related article lists in AnQiCMS to enhance user browsing?

In content operations, guiding users to continuously explore within the site, extending their stay time, is one of the key strategies to improve user experience and website conversion rates.The list of relevant articles is an efficient tool to achieve this goal.AnQiCMS as a high-performance, flexible content management system provides various ways to cleverly display related articles, thereby deeply tapping into the browsing potential of users.Why is the related article list so important?

2025-11-08