How to display the user comment list on the article detail page?

Calendar 81

User comments are an indispensable part of the website content ecosystem. They not only effectively enhance the interactivity of content, increase user engagement, but also bring a wealth of UGC (User Generated Content) to the website, helping with SEO optimization and fostering a community atmosphere.AnQiCMS as a powerful content management system fully considers this need and provides a flexible and efficient way to integrate the user comment list into your article detail page.

Next, we will explore how to easily display and manage user comment lists on the article detail page in AnQiCMS.

Step 1: Make sure the comment feature is ready and prepare the template file

Before we begin, we need to confirm that the comment feature of the AnQiCMS backend is active.Although AnQiCMS supports the comment feature by default, but for practice, you can visit the "Function Management" menu in the background to find the "Content Comment Management" option.This is the center where you manage all comments uniformly.At the same time, if you want to add a captcha to the comment form to prevent spam comments, you can enable the 'Leave a comment captcha' feature under 'Content Settings' in 'Backend Settings', which will provide support for subsequent form integration.

The template file for the article detail page is usually located in your theme directory, the path is similar totemplate/{您的模板目录}/{模型table}/detail.htmlFor example, if your article belongs to the "article model", then the file may betemplate/default/article/detail.html. Open this file and we will add the code to display the comment list.

Step two: Integrate the comment list on the article detail page

In your article detail page template, we can make use of the AnQiCMS providedcommentListThe tag can be used to retrieve and display comment data. This tag is very flexible and can help us pull comments from specific articles, and supports regular list display or pagination display.

First, you need to know the unique identifier (ID) of the current article. This ID is usually provided througharchiveDetailtags automatically, which can be used directlyarchive.Idto refer to.

The following is usedcommentListTags display the basic structure of the comment list:

"`twig {# Assuming the article ID has been obtained through archive.Id #}

<h2>用户评论</h2>
{% commentList comments with archiveId=archive.Id type="list" limit="10" %}
    {% for item in comments %}
        <div class="comment-item">
            <div class="comment-header">
                <span class="user-name">
                    {% if item.Status != 1 %}
                        {# 评论状态为非1表示审核中,可以显示“审核中”或隐藏部分信息 #}
                        审核中:{{ item.UserName|truncatechars:6 }}
                    {% else %}
                        {{ item.UserName }}
                    {% endif %}
                </span>
                {% if item.Parent %}
                    {# 如果是回复评论,显示回复对象 #}
                    <span class="reply-to">回复 {{ item.Parent.UserName }}</span>
                {% endif %}
                <span class="comment-time">{{ stampToDate(item.CreatedTime, "2006-01-02 15:04") }}</span>
            </div>
            <div class="comment-content">
                {% if item.Parent %}
                    {# 如果是回复,可以引用上级评论内容 #}
                    <blockquote class="blockquote-parent">

Related articles

How to display the WeChat QR code of the website or customize social media links?

In today's digital marketing era, the close integration of websites and social media is crucial for enhancing user interaction and brand influence.AnQiCMS as an efficient content management system fully considers the user's needs and provides a flexible and convenient way to display the WeChat QR code of the website and various custom social media links.In order to make it convenient for users to add WeChat consultation or guide them to visit your Facebook, Twitter, and other platforms, AnQiCMS can help you easily achieve this, making your website a bridge connecting users.### Step 1

2025-11-09

How to display the contact information, phone number, address, and other contact methods set on the website?

In modern website operation, clearly displaying the company's contact information is a key link in building trust and facilitating communication with users.AnQiCMS (AnQiCMS) knows this well, providing you with an intuitive and flexible backend settings, allowing you to easily manage and display the contact information, phone number, address and other information of the website.This article will introduce in detail how to set and display these important contact information in Anqi CMS.### One, configure your contact information in the Anqi CMS backend All contact information displayed on the website front end first needs to be unified managed in the Anqi CMS backend

2025-11-09

How to display breadcrumb navigation on a page to improve user experience?

In modern web design, breadcrumb navigation has become a standard element to enhance user experience and website usability.It acts as a guide for users to advance, clearly showing the user's current position in the website's hierarchy structure and providing a convenient way to return to the parent page.For websites built using AnQiCMS, integrating breadcrumb navigation can greatly facilitate visitors and also play a positive role in search engine optimization (SEO).Why is breadcrumbs navigation so important? Imagine

2025-11-09

How to display the website filing number and copyright information in the footer?

In website operation, the website footer usually contains important information, such as filing number and copyright statement.This information is not only a manifestation of the website's compliance, but also a window for displaying the website's professionalism.AnQiCMS provides a convenient way to manage and display this information.We will introduce in detail how to display the filing number and copyright information in the footer of the AnQiCMS website.

2025-11-09

How to integrate the comment submission form and handle user comments?

In modern website operations, user comments are an important way to enhance the interactivity and activity of content.AnQiCMS (AnQiCMS) offers a powerful and flexible comment feature, allowing you to easily integrate a comment submission form on your website and effectively manage user comments.Next, we will explore how to achieve this goal in AnQiCMS together.

2025-11-09

How to implement the like function for comments?

User interaction is an important manifestation of website vitality, which can significantly enhance the attractiveness and user stickiness of content.AnQi CMS is a powerful and highly customizable content management system that provides a rich set of features to enhance user engagement.Among them, the comment function is the core battlefield of user communication, and adding a like function to the comments can undoubtedly further stimulate community vitality and allow users to give more direct and positive feedback to high-quality comments.### Overview of AnQi CMS Comment Function AnQi CMS is built-in with a comprehensive comment management system, allowing website visitors to easily comment on articles

2025-11-09

How to build a custom website contact form?

The website feedback form is an important bridge for interaction between the website and visitors. Whether it is to collect user feedback, customer inquiries, or other interactive needs, a well-designed and functional feedback form is crucial.In Anqi CMS, building a custom message form is much simpler and flexible than you imagine.The built-in 'website message' function provides a powerful basic framework, allowing us to customize deeply according to actual needs. Next, we will discuss in detail how to build a custom message form in Anqi CMS that meets your specific needs.

2025-11-09

How to add captcha functionality to a message or comment form?

During the operation of the website, the message and comment function is an important channel for enhancing user interaction and collecting feedback.However, the spam comments and malicious submissions that follow often bother website administrators.To effectively prevent these unexpected guests, adding a captcha function to the comment or message form is particularly important.AnQi CMS as a comprehensive content management system provides a convenient way to integrate this security mechanism, helping you maintain a clean, efficient interactive platform.### Preparation Before adding a captcha to your comment or message form

2025-11-09