How does AnQiCMS implement pagination display on the article list page?

Calendar 👁️ 66

In website content operation, especially when the list content of articles, products, and other items becomes increasingly rich, how to efficiently display this information while ensuring user experience and website performance is a problem that requires careful consideration.A long list page not only loads slowly, but also makes visitors tired.It is particularly important to reasonably introduce the pagination display function at this time.

AnQiCMS as a powerful content management system, fully considers this operation demand.It provides intuitive and flexible template tags, helping us easily implement pagination display of article lists, making the website content clear and orderly, while also considering access speed and the convenience of user browsing.

Enable pagination mode for article list

To implement the pagination display of article lists in AnQiCMS, we mainly use two core template tags:archiveListandpaginationFirstly, we need to usearchiveListLabel to retrieve article data and clearly inform the system that we want to display these contents in a paginated form.

In the template file, when you need to display a paged article list, you can use it in this wayarchiveListTags:

{% archiveList archives with type="page" limit="10" %}
    {# 循环输出每页的文章内容 #}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">
            <h5>{{item.Title}}</h5>
            <div>{{item.Description}}</div>
            <div>
                <span>{% categoryDetail with name="Title" id=item.CategoryId %}</span>
                <span>{{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                <span>{{item.Views}} 阅读</span>
            </div>
        </a>
        {% if item.Thumb %}
        <a href="{{item.Link}}">
            <img alt="{{item.Title}}" src="{{item.Thumb}}">
        </a>
        {% endif %}
    </li>
    {% empty %}
    <li>
        该列表没有任何内容
    </li>
    {% endfor %}
{% endarchiveList %}

In this code block,archiveList archives with type="page" limit="10"It is the key.

  • archivesIt is a variable name we define, which will carry the article data of the current page. You can name it as needed.
  • type="page"Clearly inform AnQiCMS that this is a paginated list. Only by settingtype="page",paginationthe tag can be correctly identified and page information generated.
  • limit="10"It sets the number of articles displayed per page, here it is 10 articles per page. You can adjust this value based on website design and content density.

By{% for item in archives %}We can loop through and display each article on the current page one by one, including the article title, description, category, publication time, and view count. If the current list has no articles,{% empty %}The content of the block will be displayed.

Carefully crafted pagination navigation

It is not enough to simply display a list of articles; users also need a clear and easy-to-understand pagination navigation to browse the content of different pages. At this point,paginationtags come into play. They can be used to classify and organize content.archiveListTag gets the pagination data, automatically generates 'Home', 'Previous Page', 'Next Page', and specific page number links.

paginationTags usually follow.archiveListAfter the tag, it is used to display pagination navigation, here is an example of its usage:

    {# 分页代码 #}
    <div class="pagination">
        {% pagination pages with show="5" %}
            <ul>
                <li>总数:{{pages.TotalItems}}条,总共:{{pages.TotalPages}}页,当前第{{pages.CurrentPage}}页</li>
                <li class="page-item {% if pages.FirstPage.IsCurrent %}active{% endif %}"><a href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a></li>
                {% if pages.PrevPage %}
                    <li class="page-item"><a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a></li>
                {% endif %}
                {% for item in pages.Pages %}
                    <li class="page-item {% if item.IsCurrent %}active{% endif %}"><a href="{{item.Link}}">{{item.Name}}</a></li>
                {% endfor %}
                {% if pages.NextPage %}
                    <li class="page-item"><a href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a></li>
                {% endif %}
                <li class="page-item {% if pages.LastPage.IsCurrent %}active{% endif %}"><a href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a></li>
            </ul>
        {% endpagination %}
    </div>

Let's interpret it in detailpaginationParts of the tag:

  • pagesThis is a custom variable name that contains all the information related to pagination, such as the total number of articles (TotalItems)、total number of pages (TotalPages)、current page (CurrentPage) and so on.
  • show="5"The parameter controls the maximum number of page numbers displayed in the middle page area. In this example, it will display up to 5 page number links before and after the current page.
  • In{% pagination pages with show="5" %}and{% endpagination %}Among them, we can flexibly organize the HTML structure of pagination navigation.
  • pages.FirstPage/pages.LastPage/pages.PrevPage/pages.NextPageThey represent the objects of home page, last page, previous page, and next page, and they all containName(display name) andLink(Link address).
  • pages.Pagesis an array that contains the pagination objects in the middle. We can traverse these page numbers by{% for item in pages.Pages %}and useitem.Nameanditem.Linkto generate page links.
  • {% if pages.FirstPage.IsCurrent %}active{% endif %}Such conditional judgment can help us add specific CSS styles to the current page number, improving the user experience.

Comprehensive Application Example

toarchiveListandpaginationTo combine labels, a complete and functional pagination page of an article list is constructed. For example, an article list pagearticle/list.htmlThe core code may look like this:

{# 列表页面顶部可能包含面包屑、分类信息等 #}

<div class="article-list-container">
    <ul>
        {% archiveList archives with type="page" limit="10" %}
            {% for item in archives %}
            <li class="article-item">
                <a href="{{item.Link}}">
                    <h3>{{item.Title}}</h3>
                    <p>{{item.Description}}</p>
                    <div class="meta">
                        <span>分类: {% categoryDetail with name="Title" id=item.CategoryId %}</span>
                        <span>发布日期: {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
                        <span>浏览量: {{item.Views}}</span>
                    </div>
                </a>
            </li>
            {% empty %}
            <li class="no-content">
                当前分类下还没有文章哦。
            </li>
            {% endfor %}
        {% endarchiveList %}
    </ul>

    {# 分页导航区域 #}
    <div class="pagination-nav">
        {% pagination pages with show="5" %}
            <div class="summary">
                共 {{pages.TotalItems}} 篇文章,分 {{pages.TotalPages}} 页,当前第 {{pages.CurrentPage}} 页
            </div>
            <ul class="page-numbers">
                <li class="{% if pages.FirstPage.IsCurrent %}active{% endif %}">
                    <a href="{{pages.FirstPage.Link}}">{{pages.FirstPage.Name}}</a>
                </li>
                {% if pages.PrevPage %}
                <li>
                    <a href="{{pages.PrevPage.Link}}">{{pages.PrevPage.Name}}</a>
                </li>
                {% endif %}
                {% for item in pages.Pages %}
                <li class="{% if item.IsCurrent %}current{% endif %}">
                    <a href="{{item.Link}}">{{item.Name}}</a>
                </li>
                {% endfor %}
                {% if pages.NextPage %}
                <li>
                    <a href="{{pages.NextPage.Link}}">{{pages.NextPage.Name}}</a>
                </li>
                {% endif %}
                <li class="{% if pages.LastPage.IsCurrent %}active{% endif %}">
                    <a href="{{pages.LastPage.Link}}">{{pages.LastPage.Name}}</a>
                </li>
            </ul>
        {% endpagination %}
    </div>
</div>

A friendly reminder and practical suggestions:

  • Customize the style:The above code only provides the HTML structure, you can customize it according to the overall style of the website, to.pagination-nav/.page-numbers/.currentAdd custom CSS styles to the class name to make it beautiful and easy to use.
  • Reasonable settingslimitValue: limitThe parameter determines the number of articles displayed per page.Too few may cause frequent page flipping, and too many may affect page loading speed and user browsing efficiency.Suggest adjusting according to the content type and user habits.
  • SEO friendliness:AnQiCMS has taken SEO factors into account in the generation of pagination links, in conjunction with its built-in pseudo-static feature, it can ensure that pagination pages can be correctly crawled and indexed by search engines.

By following these steps, you can easily implement the pagination function of the article list in AnQiCMS, providing visitors with a more smooth and efficient browsing experience.

Frequently Asked Questions (FAQ)

Q1: How do I fix the incorrect pagination page number display or the inability to jump with a click?

A1:First, please checkarchiveListin the tagtypewhether the parameters are set as"page". If not,paginationThe label cannot retrieve the correct pagination data. Secondly, confirm that the HTML structure of the pagination navigation in your template file is correctly referenced.pagesVariables and their sub-properties (such aspages.FirstPage.Linkwait).Finally, if the website uses pseudo-static, make sure the pseudo-static rules are configured correctly and can correctly parse pagination URLs.In most cases, the default pseudo-static rules of AnQiCMS can well support pagination.

Q2: How to adjust the number of articles displayed per page?

A2:The number of articles displayed per page is controlled byarchiveListlabel'slimitthe parameter. For example, if you want to display 15 articles per page, just setlimit="10"is modified tolimit="15"It will be adjusted. After adjustment, AnQiCMS will automatically recalculate the total number of pages and pagination links.

Q3: Will the pagination feature affect the website's search engine optimization (SEO)?

A3:AnQiCMS has considered SEO factors when designing the pagination feature. It generates standardized pagination links and is usually passed throughrel="next"andrel="prev"Property (if the template supports output) indicates the relationship between pages to search engines, avoiding duplicate content issues. Just set it reasonablylimitEnsure that each pagination page has enough unique and high-quality content, and cooperate with the powerful SEO tools of AnQiCMS (such as Sitemap generation, static URLs, etc.), the pagination feature will not have a negative impact on the website's SEO, but will improve the user experience and indirectly promote the SEO effect.

Related articles

How to determine in the template whether the current page is an article detail page or a category list page, and display different content?

In the template development of Anqi CMS, it is a common requirement to display different content according to the type of the current page (whether it is an article detail page or a category list page).This not only makes the website user experience more personalized, but also provides more fine-grained control in SEO optimization.Luckyly, AnQi CMS's powerful template engine provides an intuitive way to determine the context of the current page and conditionally render accordingly.Understanding AnQi CMS template context The AnQi CMS template engine is very intelligent, it renders pages at runtime

2025-11-08

How to enable automatic image compression and WebP format conversion in AnQiCMS to improve page loading speed?

In today's fast-paced online environment, website loading speed has become a key indicator of user experience and search engine rankings.If your website has many images, they may be slowing down your website speed quietly.Fortunately, AnQiCMS fully considers this point and provides us with automatic image compression and WebP format conversion functions, which can effectively accelerate page loading and make your website fly.Why is image optimization so important?\n\nImagine when a user visits a page, if the images take a long time to display or load slowly

2025-11-08

How to safely output article content containing HTML tags in AnQiCMS templates (to prevent XSS)?

When processing article content that contains HTML tags in AnQiCMS templates, securely outputting is a crucial issue, as it directly concerns the safety and user experience of the website.Especially when the content of the article may be input by the background rich text editor, or when comments and messages submitted by users contain custom HTML, improper handling is likely to be attacked by cross-site scripting (XSS).AnQiCMS as a content management system that focuses on security and efficiency, provides the corresponding mechanisms to help us meet this challenge.Understanding Risk

2025-11-08

How to set and display the website filing number and copyright information at the bottom of the AnQiCMS page?

The website's filing number and copyright information are important elements that demonstrate the compliance and professionalism of the website. They usually appear in the footer, providing visitors with a sense of trust.In AnQiCMS, setting and displaying this information is simple and efficient.We will guide you through this process, ensuring that the key content is clearly presented at the bottom of your website. ### Step 1: Set the record number and copyright information in the AnQiCMS background First, log in to your AnQiCMS background management interface. This is the starting point of the basic information configuration for all websites. 1. **Navigate to the global feature settings:**

2025-11-08

How to set and call the TDK (Title, Description, Keywords) on the AnQiCMS backend homepage?

In AnQiCMS, the TDK (Title, Description, Keywords) settings on the homepage are an indispensable part of website SEO optimization, directly affecting the first impression of the website by search engines and the willingness of users to click on the search results and enter the website.AnQiCMS as a highly SEO-friendly content management system provides an intuitive and convenient way to manage this key information.

2025-11-08

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

In content operations, the value of a high-quality article is not only in itself, but also in its ability to guide readers to discover more valuable content.Properly displaying a list of related recommended content at the bottom of the article detail page is an effective strategy to improve user experience, extend visit duration, and reduce the bounce rate.For users of AnQiCMS, implementing this feature is quite direct and flexible.AnQiCMS with its concise and efficient architecture provides powerful template customization capabilities for content managers.Implement related recommendations for the article detail page

2025-11-08

How to call and render a custom Banner carousel in AnQiCMS template?

How to easily call and render a custom Banner carousel in AnQiCMS template?In website operation, the Banner carousel is an important element to enhance the visual appeal of the page, convey core information, and guide user behavior.AnQiCMS as a powerful content management system provides users with flexible ways to manage and call these custom Banners, allowing your website content to be displayed in a more vivid and dynamic way.### One, Back-end Management: Prepare content for Banner Carousel In AnQiCMS

2025-11-08

How to set the timing publication function when publishing articles, so that the content is displayed at the specified time?

## Master the Anqi CMS article scheduling publishing function: Let your content go online automatically during the golden time slot The timing of content release is often crucial in content operation.In order to coordinate with marketing campaigns, seize the peak of user activity, or simply maintain a stable rhythm of content output, the scheduling publishing feature is an indispensable tool for website operators.AnQi CMS understands this and provides an intuitive and convenient timed publishing option to make your content management more automated and efficient.When we carefully prepare a new article, hoping it will meet the readers at a specific time

2025-11-08