How can I design a dedicated display template for the article list in AnQi CMS?

Calendar 👁️ 61

In Anqi CMS, designing a dedicated display template for the article list is a key step in creating a unique website style and optimizing user experience.AnQi CMS provides us with great flexibility with its flexible content model and powerful template engine (similar to Django syntax), allowing us to present a diverse list of articles based on different content types, marketing goals, or user needs.

The article list page of the website is like a content showcase, how to arrange and highlight the key points directly affects the visitor's browsing interest and conversion effect.A well-designed list template that not only makes the content clear at a glance but also brings visual pleasure and improves SEO performance through reasonable layout.Let's explore step by step how to achieve this goal in Anqi CMS.

Step 1: Understand the template basics of Anqi CMS

Before starting the design, we need to first understand some basic conventions of the template files in Anqi CMS. All template files are stored in/templateUnder the directory. When you create a new template, you usually create a template folder for your website in this directory and organize your HTML files in it.

For the article list, AnQi CMS provides a very flexible template matching mechanism. It will search for the most matching template file according to certain rules:

  • Firstly, it will look for the targetSpecific Category IDList template, format is{模型table}/list-{分类ID}.html. For example, if your "News" category ID is 123 and news belongs to the "Article Model" (default table name isarchive), then the system will first look forarchive/list-123.html.
  • If it cannot find a template for a specific category, it will look for one that is suitable forthe entire modelcommon list template, formatted as{模型table}/list.htmlFor example,archive/list.htmlIt will serve as the default template for all article lists.
  • Above, there are some more general template rules, but for list pages, we mainly focus on the above two, which can meet the vast majority of customization needs.

The AnQi CMS template syntax is similar to Django, variables are enclosed in double curly braces{{变量}}Enclosed, logical control (such as conditional judgment, loop) is enclosed in single curly braces with a percentage sign{% 标签 %}Familiarize yourself with these 'magic incantations', and you will be able to call and display data freely in the template.

Step two: create your exclusive list template file by hand.

Now we know the location and naming rules of the template, we can start to get to work.

  1. Determine the customization target:Do you want to design a unified new style for all article lists? Or do you want to design a unique list page for a specific category (such as "Industry News", "Product Cases")?

    • If you wishTo globally modify all article listsof the style, you can create aarchive/list.htmlfile (if it does not exist, or modify the existing one).
    • If you want toCustom category creationYou need to know the ID of the category. For example, the ID of the 'Science and Technology News' category is456Then you can create aarchive/list-456.htmlfile.
  2. Choose the starting point:The simplest way is to copy an existing list template as a starting point for modification. Usually, you can intemplate/default/archive/list.htmlOrtemplate/default/product/list.htmlFind a basic list structure. Copy this file to your custom template directory and rename it according to the naming rules.

  3. Edit the template file:Open this new template file with the code editor you are accustomed to.We will write the HTML structure here and embed the template tags provided by Anqi CMS to dynamically display content.

Step 3: Call the article data in the template

In the custom article list template, the most critical task is to call and display article data. Anqi CMS providesarchiveListtags to complete this task.

  1. Get article list:We usearchiveListTag to retrieve article data. To support pagination, we need to settype="page". At the same time, you can uselimitparameter to control the number of articles displayed per page, for examplelimit="10"It indicates that 10 articles are displayed per page. If you want to specify the articles of a certain category, you can usecategoryIdparameters, for examplecategoryId="123". If this template is designed for a specific category,categoryIdIt can be omitted, the system will automatically identify the current category.

    {% archiveList archives with type="page" limit="10" %}
        {# 在这里循环遍历文章 #}
    {% endarchiveList %}
    

    here,archivesIt is a variable name, it will receive the list of article data, and you can also change it to another name you like.

  2. Loop to display each article: archivesIt is an array object containing multiple articles, we need to useforLoop to iterate over and display the details of each article.

    {% archiveList archives with type="page" limit="10" %}
        {% for item in archives %}
            <div class="article-item">
                <a href="{{ item.Link }}" class="article-title">
                    <h3>{{ item.Title }}</h3>
                </a>
                {% if item.Thumb %}
                    <a href="{{ item.Link }}" class="article-thumbnail">
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}" loading="lazy">
                    </a>
                {% endif %}
                <p class="article-description">{{ item.Description }}</p>
                <div class="article-meta">
                    <span>发布日期:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                    <span>阅读量:{{ item.Views }}</span>
                    <span>分类:<a href="{% categoryDetail with name='Link' id=item.CategoryId %}">{% categoryDetail with name='Title' id=item.CategoryId %}</a></span>
                </div>
            </div>
        {% empty %}
            <p>该分类下暂时没有文章。</p>
        {% endfor %}
    {% endarchiveList %}
    

    In this example:

    • item.Title: Article title
    • item.Link: Article link
    • item.Thumb: Article thumbnail (display if it exists)
    • item.Description: Article Summary
    • stampToDate(item.CreatedTime, "2006-01-02"): Format the article creation timestamp to the "Year-Month-Day" format.
    • item.Views: Article views.
    • categoryDetail with name='Title' id=item.CategoryIdandcategoryDetail with name='Link' id=item.CategoryId: Passitem.CategoryIdGet the name and link of the category to which the current article belongs.

The fourth step: add the 'Page Elf' to the list

A complete article list naturally can not be without pagination features, which can help visitors easily browse a large amount of content and is also very friendly to SEO

Related articles

How to customize the content display layout of the Anqi CMS homepage?

Your website's homepage is the first impression for visitors, as well as the showcase of the brand image and core content.How to make this "facade" both aesthetically pleasing and efficient in conveying information is a concern for every website operator.AnQiCMS (AnQiCMS) as a content management system that focuses on customization and flexibility, provides us with a very convenient way to freely create a dedicated homepage layout.

2025-11-08

How to ensure that the website content of AnQi CMS adapts to display on different devices (PC, mobile)?

One of the most painful problems we face in running websites in this multi-screen era is how to make the content of the website display effectively on different devices.Users may browse using a PC, smartphone, or tablet. If the content does not adapt to display, the user experience will be greatly reduced.AnQiCMS (AnQiCMS) provides a very mature and flexible solution in this aspect, aiming to ensure that your website content looks pleasing on any device.### AnQiCMS' Various Content Adaptation Modes AnQiCMS understands that different websites have different needs

2025-11-08

How does AnQi CMS display the prompt information when the website is closed?

During the operation of the website, we often encounter situations where we need to maintain, upgrade the website, or temporarily close the website for some special reasons.How can you inform the visitor in a friendly manner about the current status of the website, to avoid them seeing a chaotic or error page, which is particularly important.AnQiCMS (AnQiCMS) fully considers this requirement, built-in convenient and flexible shutdown prompt function, allowing you to easily deal with such scenarios. ### Flexible website status configuration, easily enable shutdown mode The shutdown function of Anqi CMS is very intuitive to configure. You just need to log in to the website backend

2025-11-08

How to display custom site parameters on the front-end page?

When operating a website, we often encounter such needs: we need to display some flexible and variable site information on the front-end page, such as the company's establishment year, customer service hotline, promotional slogans for specific pages, or a brief announcement, etc.This information may need to be updated frequently, and it is inefficient and prone to errors to modify the template file each time.Fortunately, Anqi CMS has provided us with a very convenient way to manage and display customized site parameters on the back-end, making content operation more efficient and flexible.

2025-11-08

What ways does AnQi CMS support to individually present the detailed content of a single document?

When using AnQi CMS to manage website content, if you want each document's detailed content to be presented in a unique and eye-catching way, the system provides very flexible customization settings.This is not just about changing the text color or font size, but also about deep customization from content structure to display form.Firstly, the foundation of personalized display lies in **content model and custom fields**.Our AnQi CMS allows us to create different content models based on actual business needs, such as 'articles', 'products', 'news', and even 'cases'.

2025-11-08

How can you implement a unique display style for content under a specific category in AnQi CMS?

In website operation, we often encounter such needs: a particular content category needs a unique display style to highlight the importance, uniqueness, or brand character of its content.For example, your 'news center' may require a concise list layout, while 'selected cases' may require a more visually striking grid layout or slideshow display.AnQiCMS provides powerful template customization capabilities, making it intuitive and efficient to achieve this goal.Why do you need to customize the display style for a specific category?A unified website style is indeed important

2025-11-08

How to utilize the multi-site feature of Anqi CMS to achieve unified or differentiated display of content between different sites?

The multi-site feature of AnQi CMS is an extremely powerful feature, which provides unprecedented flexibility for website operators, whether it is managing multiple independent brand websites or building a content-sharing matrix, they can handle it with ease.The core of this feature lies in the fact that it allows you to efficiently manage and display multiple independently operated websites under a single secure CMS system, and cleverly balances content differentiation and unity.### Understanding the multi-site capability of AnQi CMS Firstly, we need to clarify the operation mode of the multi-site function of AnQi CMS

2025-11-08

How to count the frequency of a keyword in a string in the AnQiCMS template?

In content operation, we often need to process and analyze text.This may involve checking keyword density to optimize search engine rankings, or it may just be to understand the frequency of a specific word appearing in the content in order to better assess the focus of the content.AnQiCMS (AnQiCMS) boasts its high efficiency and customizable features, providing users with powerful content management capabilities, and its flexible template system makes it easy for us to handle various content display needs.Today, let's talk about a very practical feature: how to count the number of times a keyword appears in a string in a template

2025-11-08