As an experienced senior personnel proficient in Anqing CMS content operation, I know that the efficiency of website information management is crucial for attracting and retaining users.Especially contact information such as this basic yet critical information, its unified management and flexible use is the foundation for improving operational efficiency and ensuring the accuracy of information.Below, I will give a detailed introduction on how to call the contact information set in the AnQiCMS template.
Unified management of contact information in AnQiCMS backend
In AnQiCMS, the contact information of the website is centrally managed, which greatly simplifies the content update process.You do not need to modify the template file to quickly update the phone, address, and email information of the website.These settings are located under the 'Contact Settings' option in the 'Background Settings' menu.
On this interface, AnQiCMS provides many default contact information fields, such as contact person (UserName), phone number (Cellphone), contact address (Address), contact email (Email), WeChat ID (Wechat) and WeChat QR code (Qrcodeetc.In addition, to meet the personalized needs of different websites, AnQiCMS also supports custom settings parameters.You only need to provide a "parameter name" (for template calls, it is recommended to use letters and follow camel case naming), a "parameter value", and a "note" to identify its purpose, and you can easily expand the contact information field.
In this way, website operators can manage all external contact information in one place, ensure consistency of the entire site data, and quickly take effect when updates are needed, avoiding omissions and errors that may occur when manually modifying multiple template files.
Contact information is called in AnQiCMS template
AnQiCMS template engine adopts a syntax structure similar to Django, variable output uses double curly brackets{{变量}}where logical control uses single curly braces and the percent sign{% 标签 %}The contact information set in the background depends mainly on the built-incontact.
contactThe design principle of the tag is to simply and efficiently obtain the contact information configured in the background. Its basic usage method is{% contact 变量名称 with name="字段名称" %}.Where,“field name”is the identifier of the corresponding field in the background“contact information settings”.If you choose to provide a 'variable name', the value of this field will be assigned to this variable for subsequent use in the template; if no 'variable name' is specified, the tag will output the value of the field directly.
Here are specific examples of calling each contact information field:
Calling contact information
If you want to display the contact name set in the background in the template, you can use the following method:
<span>联系人:{% contact with name="UserName" %}</span>
Or, if you want to assign the value to a variable and then use it:
{% contact agentName with name="UserName" %}
<span>联系人:{{agentName}}</span>
Call the contact phone number
To display the contact phone number, you willnameset the attribute toCellphone:
<span>联系电话:{% contact with name="Cellphone" %}</span>
On mobile, you can also wrap it intel:the link for easy clicking and dialing:
<a href="tel:{% contact with name="Cellphone" %}" rel="nofollow">联系电话:{% contact with name="Cellphone" %}</a>
Call contact address
For the physical address of a company or store, useAddressField:
<span>联系地址:{% contact with name="Address" %}</span>
Call the contact email
Display the company's external email address,nameThe attribute should beEmail:
<span>联系邮箱:<a href="mailto:{% contact with name="Email" %}">{% contact with name="Email" %}</a></span>
Call WeChat number and WeChat QR code
For WeChat information, you can call WeChat number text and QR code image separately:
<span>微信号:{% contact with name="Wechat" %}</span>
<div class="wechat-qrcode">
<img src="{% contact with name="Qrcode" %}" alt="微信二维码" />
</div>
Call other built-in social media contact methods
AnQiCMS also includes contact fields for social media platforms such as QQ, WhatsApp, Facebook, Twitter, Tiktok, Pinterest, Linkedin, Instagram, and Youtube.You can set it in the background as needed and call it according to the corresponding field name.
<span>WhatsApp:{% contact with name="WhatsApp" %}</span>
Call custom settings parameters
If you have added custom parameters in the "Contact Information Settings" backend, for example, you have created a namedServiceHotlineThe parameter is used to display the 24-hour service hotline, you can call it like this in the template:
<span>24小时服务热线:{% contact with name="ServiceHotline" %}</span>
Please note, here,ServiceHotlineShould match the parameter name set in the background when you customize the parameters and follow the camel case naming rule set in the background.
Example of practical application scenarios
Integrate this contact information into the website footer, "Contact Us" page, or header, which is a common application method. For example, a typical website footer may contain the following contact information:
<footer>
<div class="contact-info">
<p>联系人:{% contact with name="UserName" %}</p>
<p>电话:<a href="tel:{% contact with name="Cellphone" %}" rel="nofollow">{% contact with name="Cellphone" %}</a></p>
<p>邮箱:<a href="mailto:{% contact with name="Email" %}">{% contact with name="Email" %}</a></p>
<p>地址:{% contact with name="Address" %}</p>
<div class="social-links">
{% contact wechatAccount with name="Wechat" %}
{% if wechatAccount %}
<span>微信:{{wechatAccount}}</span>
{% endif %}
{% contact whatsappLink with name="WhatsApp" %}
{% if whatsappLink %}
<a href="{{whatsappLink}}" target="_blank" rel="noopener noreferrer">WhatsApp</a>
{% endif %}
<img src="{% contact with name="Qrcode" %}" alt="微信二维码" style="width: 80px; height: 80px;" />
</div>
</div>
<div class="copyright">
© {% now "2006" %} 版权所有 {% system with name="SiteName" %}
</div>
</footer>
This example demonstrates how to flexibly combinecontactlabels to display various contact methods. Use{% if %}labels can determine whether certain optional fields exist, avoiding displaying empty content when not set.
Summary
Provided by AnQiCMScontactLabel, website operators can easily dynamically call the contact information set in the background on the website template.This centralized management and flexible call mechanism not only improves the efficiency of information updates but also ensures the accuracy and consistency of the website's external information.Whether it is a standard contact field or a customized extension information, AnQiCMS can provide powerful and convenient support to help your website operate more efficiently and professionally.
Frequently Asked Questions (FAQ)
1. What will be displayed in the template if a contact information field is empty in the background?
Answer: If a field in the background "Contact Information Settings" is empty, then in the template through{% contact with name="字段名称" %}When invoked, this position will output an empty string. To avoid unnecessary whitespace or tags on the page, it is recommended that you use these optional fields when calling them.{% if %}Logic to determine if there is any content, for example:
{% contact phoneNum with name="Cellphone" %}
{% if phoneNum %}
<p>联系电话:{{phoneNum}}</p>
{% endif %}
2. How to call the contact information field that I customized in the background?
Answer: Any field you customize in the "Contact Information Settings" backend can be called using the "parameter name{% contact with name="ServiceEmail" %}Call its value. Make sure the 'parameter name' you use matches the uppercase and lowercase settings on the back-end, following camelCase naming conventions.
3. Can I call the contact information of other sites if my AnQiCMS is deployed with multiple sites?
Yes, the multi-site management function of AnQiCMS supports you to call the contact information of other sites.contactTags provide asiteIdParameter, you can obtain the contact information of other sites by specifying their ID. For example, if you want to call the phone number of a site with ID 2, you can use{% contact with name="Cellphone" siteId="2" %}. If not specifiedsiteIdThe parameter, the tag will default to getting the contact information of the current site.