In website content operation, we often need to display a list of articles under a specific category on a single page, and to provide a better user experience and content structure, pagination is usually used as well.The Anqi CMS provides powerful and easy-to-use template tags that can help us easily achieve this requirement.

The core of article content calling:archiveListtags

To call the content of articles under a specific category, Anqi CMS providesarchiveListthis core tag. This tag is very flexible and can filter and sort articles according to various conditions.

It is crucial to clearly specify the category to be called. This is achieved throughcategoryIdparameters. For example, if the ID of your 'Company News' category is 10, you can set it up like this:categoryId="10". If you need to call multiple categories of articles at once, you can separate the category IDs with English commas, likecategoryId="10,12,15". An interesting detail is that if you omitcategoryIdParameters, the system will try to read the category ID of the current page; if you explicitly do not want it to be read automatically, you can set it tocategoryId="0".

Secondly, to implement pagination of the article list,typeThe parameter must be set to 【en】."page"). Whentype="page"whenarchiveListThe tag will intelligently return the article data on the current page and simultaneously generate other information required for pagination, which will be used by subsequent pagination tags.

In addition to these two key parameters,archiveListIt supports other commonly used settings to meet diverse display requirements:

  • limit: It controls the number of articles displayed per page, for examplelimit="10"This means 10 articles are displayed per page.
  • order: Defines the sorting method of the articles, for example,"id desc"It means sorting by article ID in reverse order (i.e., the most recently published),"views desc"Indicates sorting by view count in descending order.
  • moduleIdIf your website uses a different content model (such as articles, products, etc.), you can specify the model ID through this parameter. The article model is typically set to 1 by default.

InarchiveListIn the loop of the tags, you can accessitemthe detailed information of each article, including{{item.Title}}(article title),{{item.Link}}(article link),{{item.Description}}(Abstract of the article),{{item.Thumb}}(article thumbnail),{{item.CreatedTime}}(Publish time) and{{item.Views}}[View count] etc., thus enabling flexible construction of the display style for each article.

Improve pagination navigation:paginationtags

paginationTags are witharchiveListTags (whentype="page"It is used in close cooperation with time-related functions, and it is responsible for generating beautiful and functional pagination navigation links at the bottom of the page.

When usingpaginationWhen using tags,showParameters can be used to control the number of page numbers displayed in the pagination bar. For example,show="5"It will display 5 page number links before and after the current page, making the pagination bar appear more concise and easy to navigate.

paginationA label will provide a namedpagesvariable, which contains all the data related to pagination, such as{{pages.TotalItems}}(total number of articles),{{pages.TotalPages}}(Total number of pages),{{pages.CurrentPage}}(current page) et al.It is the most important thing that it provides links and status information for home page, previous page, next page, last page, and middle page numbers.forloop to traverse, and throughpageItem.IsCurrentTo determine the current page, thus highlighting it.

Practical Exercise: Call specific category articles and implement pagination.

Here is a specific code example demonstrating how to implement the retrieval and pagination of articles in a specific category of an Anqi CMS template. Suppose we want to display the articles in a template file (for examplearticle/list.htmlDisplay all articles under the category with ID 10 that you have set a custom template for, and perform pagination.

This is the page content area, used to display the list of articles