How does AnQiCMS template call the contact parameters of the background custom settings?

In website operation, a clear and effective contact method is the bridge for users to communicate with us, and it is also an important basis for building trust.For users who use AnQiCMS to manage websites, how to flexibly call the contact information parameters set in the background in website templates is the key to improving operational efficiency and website maintainability.AnQiCMS powerful background customization features, combined with its intuitive template tags, making everything easy.

Data source: Background "Contact Settings"

When using AnQiCMS, you will find that all website basic information can be easily managed in the background. Specifically for contact information, you just need to go to the background of the “Backend settingsMenu, clickContact information settingsAs soon as

Here, AnQiCMS provides a series of built-in common contact information fields, such as: contact person, phone number, contact address, contact email, WeChat ID, WeChat QR code, as well as international social media links such as QQ, WhatsApp, Facebook, etc.You just need to fill in your information in the corresponding input box, and the system will automatically save it.

What's even better is that if these default options cannot fully meet your business needs, AnQiCMS also allows you toCustom settings parameters.For example, your business may need to display a link to an uncommon instant messaging tool or a special customer service hotline.You can add a parameter in the custom parameter area, for example, set the 'Parameter Name' to 'CustomerServiceHotline', and enter the specific number in the 'Parameter Value'.The "parameter name" is the key identifier to be called in the template, and the "parameter value" is the specific information displayed on the website.This highly customized ability ensures that your website can perfectly adapt to various complex business scenarios.

Template call: Display backend settings on the website front end

AnQiCMS's template system adopts a concise syntax similar to Django, which is very intuitive. When you need to display the contact information set in the background on the website front end, you will mainly use a name calledcontactThe template tag.

The format of using this tag is usually{% contact 变量名称 with name="字段名称" %}. Among them,变量名称It is optional, used to temporarily store the data obtained, convenient for you to repeat it in the subsequent part of the template; andname="字段名称"It is the specific parameter name defined in the background "Contact Information Settings" (whether built-in or custom).

For example, to call the contact phone number set in the background, you can write it like this:

电话: {% contact with name="Cellphone" %}

If you want to call the contact email set in the background, you can do it like this:

邮箱: {% contact with name="Email" %}

And for the WhatsApp contact method we just customized, if its parameter name is "WhatsApp", you can also call it in the following way:

WhatsApp: {% contact with name="WhatsApp" %}

You can also choose to assign the obtained value to a variable, for example{% contact myPhone with name="Cellphone" %}Then you can go through{{ myPhone }}Call this phone number. This method is very convenient when you need to process the data or refer to it multiple times.

{% contact myPhone with name="Cellphone" %}
我们的热线电话是: {{ myPhone }},欢迎随时拨打。

Moreover, if you are managing multiple sites and need to call the contact information of a specific site,contactTags also supportsiteIdparameters, for example{% contact with name="Cellphone" siteId="2" %}This will call the contact phone number of the site with ID 2. This provides great convenience for multi-site operations.

Application: Contact information display layout

In website design, contact information is usually located in the header, footer, a dedicated "Contact Us" page, or in sidebars of certain specific content. Below is an example of how to flexibly use these labels to display multiple contact details:

<div class="footer-contact-info">
    <h4>联系我们</h4>
    <p>联系人: {% contact with name="UserName" %}</p>
    <p>电话: <a href="tel:{% contact with name='Cellphone' %}">{% contact with name='Cellphone' %}</a></p>
    <p>邮箱: <a href="mailto:{% contact with name='Email' %}">{% contact with name='Email' %}</a></p>
    {% set whatsappNum = contact with name='WhatsApp' %} {# 假设后台有自定义WhatsApp参数 #}
    {% if whatsappNum %}
        <p>WhatsApp: <a href="https://wa.me/{{ whatsappNum }}" target="_blank" rel="nofollow">{{ whatsappNum }}</a></p>
    {% endif %}
    <p>地址: {% contact with name='Address' %}</p>
    {% set wechatQrcode = contact with name='Qrcode' %}
    {% if wechatQrcode %}
        <p>微信扫一扫:</p>
        <img src="{{ wechatQrcode }}" alt="微信二维码" style="width: 100px; height: 100px;">
    {% endif %}
    <p>版权所有 © {% now "2006" %} {% system with name="SiteName" %}. All Rights Reserved.</p>
</div>

In this example, we used{% if %}To label certain optional fields (such as WhatsApp and WeChat QR codes) for content existence, only display when there is content, in order to avoid empty lines or unnecessary placeholders on the page, and maintain the website's neat and professional appearance. At the same time, we also add the corresponding for phone and email.tel:andmailto:Link, convenient for users to click to dial or send an email directly.

Summary

Through the flexible "Contact Settings" function of the AnQiCMS backend, combined with the concise template ofcontactLabel, you can easily display various contact information anywhere on the website.Whether it is updating the phone number, email, or adding a new social media account, there is no need to modify the template code, just a simple operation in the background can be completed, which greatly enhances the management efficiency and flexibility of the website content.This design concept makes AnQiCMS a powerful assistant for small and medium-sized enterprises and content operation teams.


Frequently Asked Questions (FAQ)

1. What will be displayed in the template if I do not fill in a field in the background "Contact Information Settings"?

Answer: If a field is not filled in the background, it will not be displayed at this location when called in the template (i.e., it will be empty).This means that AnQiCMS will intelligently handle empty values, so you don't have to worry about placeholders like 'Phone not set' appearing on the page, maintaining the cleanliness of the website.{% if ... %}and{% else %}to achieve.

Can you display contact information for different sites on a single page?

Answer: Of course you can.contactTag supportsiteIdParameter. If you have enabled the multi-site management feature in the AnQiCMS backend and created multiple sites, you can specify to{% contact with name="Cellphone" siteId="站点的ID" %}the form, specify the