How to display a user's comment list in AnQi CMS and support multi-level replies and review status distinction?

Calendar 👁️ 56

The comment feature is an indispensable part of the website's content and user interaction, it can not only enliven the atmosphere of the website, but also provide valuable user feedback for operators.Anqi CMS understands its importance and provides a flexible and feature-rich comment system, allowing website administrators to easily display and manage user comments, while supporting hierarchical replies and review status differentiation to ensure the interactivity and quality of website content.

AnQi CMS comment feature overview

In Anqi CMS, to display the comment list of website content, it mainly relies on its powerful template tag system. The core highlight of the comment feature is:

  1. Flexible comment list display: Comments can be retrieved and displayed using the ID of the article or product.
  2. Supports multi-level replies: Users can reply to other comments, forming a clear conversation chain to enhance community interaction.
  3. Distinguish review status: The comment content can be set to require review, and after the administrator approves it from the background, it will be displayed on the front end, effectively ensuring the quality of the content.
  4. Comment paginationWhen the number of comments is high, the system supports automatic pagination to improve page loading speed and user experience.

Next, we will discuss step by step how to implement these features in the template.

Core Implementation: Template invocation for comment list

To display the comment list on the front-end page, we mainly usecommentListTemplate tag. This tag allows us to retrieve comment data based on a specific content ID.

1. Get the current content ID.

Generally, the comment list is displayed on the article or product detail page. First, we need to obtain the article or product ID corresponding to the current page. This can be done byarchiveDetailLabel implementation is easy, it can obtain detailed information about the current document, including its ID:

{% archiveDetail archiveInfo with name="Id" %}
{# 此时 archiveInfo 变量中存储了当前内容的ID #}

2. Call the comment list and enable pagination

After obtaining the content ID, we can usecommentListTag to get comment data. To better manage and display comments, we can choose to enable pagination:

{% commentList comments with archiveId=archiveInfo type="page" limit="10" %}
    {# 评论列表的循环展示内容将在这里 #}
{% endcommentList %}

Here:

  • commentsIt is the variable name we define for comment data, which will be used in the loop.
  • archiveId=archiveInfoPass the current article ID to the comment tag to tell the system which content's comments to retrieve.
  • type="page"Tell the system what pagination list we need for comments.
  • limit="10"Then set 10 comments to be displayed per page.

3. Loop to display the comment content.

commentsA variable is an array containing comment objects. We can usefora loop to iterate and display the details of each comment.itemRepresents the current comment object being cycled through, which includes fields such as comment ID, username, content, creation time, review status, and a series of other fields.

"twig {% for item in comments %}"

<div class="comment-item">
    {# 显示评论者的用户名 #}
    <span class="comment-author">{{item.UserName}}</span>

Related articles

How does the `urlize` filter in AnQi CMS automatically convert URLs in text to clickable links?

In the daily content creation and website operation, we often need to insert various links in articles, whether they point to external resources or refer to other content within the site.Manually converting these plain text URL addresses into clickable hyperlinks is undoubtedly a repetitive and error-prone task.Imagine if the amount of content on the website were massive, how much time and effort would it take to do this job?

2025-11-09

How to process front-end displayed data twice through the `filter` filter, such as truncating characters or formatting?

In Anqi CMS, data is stored in its original form, but we know that the data presented on the front end needs to be carefully crafted to present in a **pose to the users. At this point, the 'filter' in the template engine has become an indispensable tool in our hands.It can process data twice, whether it is accurately截取 long text, unify date format, or cleverly handle HTML content, it can easily cope with it, making your website content both professional and attractive.### Understanding the core role of "filter" Imagine one

2025-11-09

How does AnQi CMS generate and display thumbnails of different sizes for image resources?

In website operation, the loading speed and display effect of images directly affect user experience and search engine optimization.Especially for content management systems with a large number of images, how to efficiently generate and display thumbnails of different sizes is a crucial function.AnQiCMS (AnQiCMS) provides a flexible and powerful solution in this regard, making it easy to manage and display image resources. ### Core Advantage: Intelligent Generation and Flexible Upload AnQiCMS does a very good job in handling image resources.It is the most reassuring feature

2025-11-09

How to implement the correct rendering and style display of Markdown content in AnQi CMS template?

Markdown is favored by content creators for its concise and efficient characteristics.In AnQi CMS, using Markdown not only allows for quick content creation but also enables simple configuration to perfectly display these contents on the frontend page, including rich styles, mathematical formulas, and even flowcharts.This article will introduce in detail how to make your Markdown content render correctly and have a beautiful style in the Anqi CMS template.Enable Markdown editor First

2025-11-09

How to add captcha display to the comment feature of Anqi CMS to enhance security?

Maintaining a healthy, interactive website comment section is an indispensable part of content operation.However, comment sections often become hotbeds of spam and malicious attacks, which not only affects the quality of the website's content but also brings additional review burdens to website administrators.To effectively resist the interference of these automated programs, adding a captcha display to the comment feature of AnQi CMS is a simple and practical security enhancement measure.

2025-11-09

How can AnQi CMS display a list of recommended articles related to the current article content?

In website operation, providing a list of recommended articles related to the current content is an important strategy to enhance user experience, extend user stay time, and optimize website internal links.AnQiCMS (AnQiCMS) knows this and provides flexible and powerful features to help you easily achieve this goal.### Core Function Analysis: Related Document Tag `archiveList` To display a list of recommended articles related to the current article content in AnQi CMS, you will mainly use a very key template tag—`archiveList`

2025-11-09

How to define and display temporary variables in Anqi CMS template for complex content layout?

In website content operation, we often encounter some scenes where we need to flexibly display data and dynamically adjust the layout.Sometimes listing information simply is not sufficient to meet complex design requirements, and at this point, if you can freely define and use some temporary variables in the template, it will greatly enhance our efficiency and the expressiveness of the template.AnQiCMS (AnQiCMS) with its powerful backend developed based on the Go language and the template engine syntax similar to Django, provides us with a flexible mechanism for defining and managing temporary variables, making it possible to create exquisite and complex content layouts.Define a temporary variable

2025-11-09

How does the `breadcrumb` tag in AnQi CMS generate and display flexible breadcrumb navigation?

When building a website, a clear and intuitive navigation system is crucial for user experience and search engine optimization (SEO).Breadcrumb navigation is a tool that can significantly improve website usability, clearly showing the user's current position on the site and providing convenient links to return to the previous level page.AnQi CMS knows this and provides a powerful and flexible `breadcrumb` tag.###

2025-11-09