How to enable and configure the website comment form in AnQiCMS and display custom fields?

Calendar 78

In AnQiCMS, creating an interactive guest feedback form that can collect feedback and flexibly configure custom fields is a very practical feature.AnQiCMS provides a simple and efficient way to achieve this goal, whether it is backend settings or front-end display, it can be easily mastered.

Enable and configure the message function in the background

Generally, when you want website visitors to be able to contact you or collect their feedback, an inquiry form is the preferred choice.Enable and configure the message function in AnQiCMS, you first need to enter the background management interface.

In the left navigation bar of the background interface, find the "Function Management" menu, click on it, and you will see an option named "Website Message Management".This is where you manage and configure the core area of the guestbook form.After entering this page, you can add, edit, or delete the fields of the comment form.

AnQiCMS allows you to customize the fields of the message form according to your actual needs.This is like designing a questionnaire, where you can flexibly set various types of questions.For example, you may need visitors to fill in their name, contact phone number, email address, or opinions on a product or service.

Create a custom field when you can choose multiple field types:

  • Single-line Text (text): Suitable for names, brief answers, etc.
  • Number (number): If you need to collect numeric information such as quantity, age, etc.
  • Multiline text (textarea): Very suitable for visitors to input long comments or detailed descriptions.
  • Single choice (radio): Provide several preset options, visitors can only choose one.
  • Multiple choice (checkbox): Provide multiple options, visitors can choose one or more.
  • Dropdown selection (select)Similarly, preset options are provided, displayed in a dropdown menu.

For selection type fields (radio, checkbox, dropdown), you can directly set their default values in the background. These default values will be displayed as selectable items on the front-end.At the same time, you can mark any field as 'required' to ensure that you collect key information.This flexibility allows you to create customized comment forms for various business scenarios.

In addition, to prevent malicious submissions or spam, enabling captcha for the comment form is a wise choice.You can go to the 'Global Settings' in the background, enter the 'Content Settings' option, find and enable the captcha function.Once enabled, the comment form will require users to enter a captcha when submitting.

You may also want to be notified in time when you receive a new message.AnQiCMS also supports configuring message email reminder features to ensure you do not miss any important customer feedback.

Leave form displayed in the front-end template

The backend configuration of the message function is completed, and the next step is to display it on the front page.AnQiCMS uses a template-driven approach to display content, so you need to modify or create a dedicated comment page template.

In your template directory, there is usually oneguestbook/index.html(Or if your template uses a flattened structure, it might beguestbook.html) file, this file is used to render the留言表单页面. If you don't have this file, you can create one yourself.

In the template, you need to use the AnQiCMS providedguestbooktags to dynamically obtain the留言 fields configured in the background. The usage of this tag is very intuitive:

<form method="post" action="/guestbook.html">
    {% guestbook fields %}
        {% for item in fields %}
        <div>
            <label>{{item.Name}}</label>
            <div>
                {% if item.Type == "text" || item.Type == "number" %}
                <input type="{{item.Type}}" name="{{item.FieldName}}" {% if item.Required %}required{% endif %} placeholder="{{item.Content}}" autocomplete="off">
                {% elif item.Type == "textarea" %}
                <textarea name="{{item.FieldName}}" {% if item.Required %}required{% endif %} placeholder="{{item.Content}}" rows="5"></textarea>
                {% elif item.Type == "radio" %}
                {%- for val in item.Items %}
                <input type="{{item.Type}}" name="{{item.FieldName}}" value="{{val}}" id="{{item.FieldName}}-{{loop.index}}">
                <label for="{{item.FieldName}}-{{loop.index}}">{{val}}</label>
                {%- endfor %}
                {% elif item.Type == "checkbox" %}
                {%- for val in item.Items %}
                <input type="{{item.Type}}" name="{{item.FieldName}}[]" value="{{val}}" id="{{item.FieldName}}-{{loop.index}}">
                <label for="{{item.FieldName}}-{{loop.index}}">{{val}}</label>
                {%- endfor %}
                {% elif item.Type == "select" %}
                <select name="{{item.FieldName}}" {% if item.Required %}required{% endif %}>
                    {%- for val in item.Items %}
                    <option value="{{val}}">{{val}}</option>
                    {%- endfor %}
                </select>
                {% endif %}
            </div>
        </div>
        {% endfor %}

    {# 验证码集成,如果后台开启了验证码功能,则需要添加以下代码 #}
    <div style="display: flex; clear: both; margin-top: 15px;">
        <input type="hidden" name="captcha_id" id="captcha_id">
        <input type="text" name="captcha" required placeholder="请填写验证码" style="flex: 1; padding: 10px; border: 1px solid #ccc;">
        <img src="" id="get-captcha" style="width: 150px;height: 50px;cursor: pointer; margin-left: 10px; border: 1px solid #ccc;" />
        <script>
            document.getElementById('get-captcha').addEventListener("click", function (e) {
              fetch('/api/captcha')
                      .then(response => response.json())
                      .then(res => {
                        document.getElementById('captcha_id').setAttribute("value", res.data.captcha_id);
                        document.getElementById('get-captcha').setAttribute("src", res.data.captcha);
                      }).catch(err => console.log(err));
            });
            document.getElementById('get-captcha').click(); // 页面加载时自动获取验证码
        </script>
    </div>

    <div style="margin-top: 20px;">
        <button type="submit" style="padding: 10px 20px; background-color: #007bff; color: white; border: none; cursor: pointer;">提交留言</button>
        <button type="reset" style="padding: 10px 20px; background-color: #6c757d; color: white; border: none; cursor: pointer; margin-left: 10px;">重置</button>
    </div>
</form>

In this code snippet,{% guestbook fields %}The tag will load all field information configured on the backend. Then, through{% for item in fields %}looping, we can generate the corresponding HTML input elements according toitem.Type(field type) dynamically.item.NameUsed to display the Chinese name of the field,item.FieldNameIs the field name used when submitting the form,item.RequiredDetermines whether to add HTML5'srequiredProperty.

If you have enabled the captcha feature in the background, then make sure to ensure that the captcha-relatedinputFields and JavaScript code are also added to the form to dynamically load captcha images and perform verification.

The form'sactionattribute should point to/guestbook.htmlThis is the default processing address for message submission received by AnQiCMS.After submission, you can configure the backend to return an HTML page or JSON data for easy front-end processing.

Processing after leaving a message

After the visitor fills in and submits the message, all information will be safely stored in the 'Website Message Management' of your AnQiCMS backend.You can view all received messages there, and perform operations such as reviewing, replying, or deleting.

By following these steps, you can easily enable a fully functional website message form in AnQiCMS, and you can also flexibly customize fields according to brand and business needs to enhance the interactivity and information collection capabilities of the website.This deep customization capability is exactly what AnQiCMS is committed to providing, an efficient and customizable content management solution.


Frequently Asked Questions (FAQ)

1. Where can I view the messages I submitted?All messages submitted through the front-end form will be stored in the 'Function Management' menu under the 'Website Message Management' in AnQiCMS backend.Enter this page, you can view, manage, and reply to all received messages.

How to set options for single-choice, multiple-choice, or dropdown fields in a comment form?In An

Related articles

How to format the display of the article's publish time in the template, for example “2023 June 1st”?

When operating a website, the time an article is published is often one of the important pieces of information that users are concerned about.A clear and readable time format not only enhances user experience but also helps to improve the professionalism of website content.AnQi CMS is an efficient and customizable content management system that provides a flexible way to control the display of various information in templates, including the publishing time of articles.

2025-11-07

How to display the user's submitted comment content and avatar in the website comment section??

Displaying user comments on the website is a key element in enhancing user interaction and content vitality.For websites using AnQiCMS, its powerful template tag system makes this operation intuitive and flexible.This article will thoroughly introduce how to clearly display user-submitted comments in the website's comment section, accompanied by their unique avatars, thereby enriching the website's user experience.--- ### Understanding the Basics of AnQi CMS Comment Function Firstly, we need to understand how comment content operates in AnQi CMS

2025-11-07

How to display the article summary instead of the full text on the search results page?

How to make users quickly understand the content of the article on the search results page without directly displaying the full text, which is not only related to user experience but also a key factor in search engine optimization (SEO).For those using AnQiCMS, achieving this is very flexible and efficient.

2025-11-07

How to display personalized information on the front end based on the custom content model fields in the backend?

## Unveiling AnQi CMS: How to skillfully use custom fields in the backend to create personalized front-end content display In today's rapidly changing digital world, a website is not just a carrier of information, but also a window for brand personality and user experience.Traditional website content management systems (CMS) are often limited by fixed content structures and are difficult to meet the diverse business needs.However, AnQiCMS (AnQiCMS) has opened a new door to personalized content display for website operators with its flexible content model and powerful custom field features.

2025-11-07

How to display the website's logo image on the front page?

The website logo is the core of the brand image, it not only enhances the professionalism of the website, but also deepens users' recognition of the brand.In AnQiCMS, displaying your logo image on the front page is a straightforward and flexible process, mainly involving backend settings and template code adjustments. ### Step 1: Upload and configure your Logo on the AnQiCMS backend Managing the Logo image of the website is very convenient in AnQiCMS.First, you need to upload the Logo image to the system's backend.

2025-11-07

How to use the `tdk` tag in the template to display the current page's canonical URL?

In website operation, we all hope that our content can be accurately understood and efficiently indexed by search engines.Among them, Canonical URL (standard link) is a very important concept.It can help us solve the problem of duplicate content that may arise due to similar content or accessible from multiple URLs, clearly telling search engines which is the main version of the content, thus concentrating the ranking weight of the page and avoiding dispersion.AnQi CMS as an efficient and flexible content management system, fully considers the needs of SEO optimization, and built-in powerful TDK (Title

2025-11-07

How to display website traffic statistics in the background in the form of charts?

In website operation, understanding and analyzing traffic data is a key link in formulating effective strategies and optimizing website performance.AnQiCMS (AnQiCMS) fully understands this, and therefore provides an intuitive and convenient traffic statistics function in the background, allowing operators to easily grasp all the data of the website in the form of charts, thereby better driving content and marketing decisions.The traffic statistics feature of Anqi CMS is designed to provide a comprehensive view of website performance.It not only records the user's visit behavior, but also pays special attention to the activities of search engine spiders, which is crucial for SEO work.Through the background data statistics module

2025-11-07

How to use the `archiveFilters` tag to implement multiple condition combination filtering on the front end?

AnQiCMS provides flexible and powerful content management capabilities, one very practical feature is to use the `archiveFilters` tag to implement multi-condition combination filtering on the front-end.This undoubtedly greatly enhances the user experience and the discoverability of content for websites that are rich in content and require users to search for information based on different dimensions, such as product displays, real estate rentals, recruitment information, and so on.Let's delve deeper into how to use the `archiveFilters` tag to build an intuitive and efficient filtering system for your website.

2025-11-07