Elegantly display the contact name on the AnQiCMS template: A guide for experts
In today's increasingly popular digital marketing, a website is not just a platform for displaying information, but also a bridge for enterprises to build trust and communicate with users.A clear and accessible contact method, especially the name of the website operator, can effectively enhance the professionalism and affinity of the website, making visitors feel the real existence and responsible attitude.For enterprises using an AnQiCMS-like enterprise-level content management system, how to efficiently and flexibly display these key information in templates is a core skill that website operators need to master.
AnQiCMS is an efficient content management system developed based on the Go language, which has fully considered the customizability and ease of use of content from the beginning of its design.It deeply understands the needs of small and medium-sized enterprises and content operation teams for flexibility in information display, and therefore provides strong support in terms of template tags and backend configuration.Today, let's delve deeply into how to accurately display the contact name of the website in the AnQiCMS template.
I. Backend configuration of the contact name: the source of data
Any content displayed on the front end cannot do without the careful configuration of the backend.In AnQiCMS, the setting of contact name is located in a straightforward and easy-to-operate position, which reflects its "lightweight and efficient" design concept.
You can navigate to the AnQiCMS backend by accessing“Background Settings”and then selectthe "Contact Information Settings". On this interface, you will see a series of preset contact information fields, such as contact person, contact phone number, contact address, contact email, etc.Among them, the "Contact" field is the core we are focusing on today.
When you enter specific names such as 'Mr. Wang' or 'Ms. Li' in the 'Contact' field and save them, this information is like the blood of the website, infused into the AnQiCMS data center, ready for the template to call at any time.It is worth mentioning that AnQiCMS also supports custom contact information parameters.If you have more personalized needs, such as displaying "Pre-sales consultant: Zhang Manager" or "Technical support: Zhao Engineer" in addition to the general term "contact", you can add custom parameters in the "Contact information settings".For example, you can add a parameter namedSalesContactand fill in 'Manager Zhang'. Such a design greatly enhances the flexibility of content operations.
The way of calling in the template:contactThe art of tags
AnQiCMS's template system adopts a syntax style similar to Django template engine, which makes the invocation of technical information in the template intuitive and logical. To display the contact name set in the background, we mainly rely on a namedcontactThe dedicated template tag.
The design intention of this tag is to facilitate website operators to call all data related to 'Contact Settings' in templates. Its basic usage is{% contact 变量名称 with name="字段名称" %}.
Now, let's focus on how to display the contact name:
Directly call the preset field
UserNameIn the "Contact Information Settings", the internal identifier of the "Contact" field we enter in the template isUserNameTherefore, if you want to display this contact name directly in the template, you can use it like thiscontactTags:<div>网站联系人:{% contact with name="UserName" %}</div>The above code will directly output the content you have filled in the "Contact" field in the "Contact Information Settings" backend.
Invoke by variable name to enhance readability and reusability.: In order to make the template code more readable and convenient for repeated references to the same data in the same template area, you can
contactThe value obtained by the tag is assigned to a variable. For example, you can assign the name of the contact to a variable namedsiteContactPerson:“{% contact siteContactPerson with name="UserName" %} <p>尊敬的访客,欢迎联系:{{ siteContactPerson }}</p>Thus,
{{ siteContactPerson }}and it can be used{% contact %}and{% endcontact %}between tags without having to call it againcontact.Invoke custom contact information fieldAs mentioned earlier, AnQiCMS allows you to add custom contact parameters in the background. For example, you have created a parameter named
SalesContactThe custom parameter. Then, the way to call this custom field in the template is the same as that of the preset fields, just replacenameThe parameter value with your custom parameter name:{% contact salesManager with name="SalesContact" %} <p>售前咨询:{{ salesManager }}</p>This consistent calling method greatly reduces the learning cost and complexity of template development.
Precise calling in multi-site environments A powerful feature of AnQiCMS is the support for multi-site management. If you are managing multiple websites through AnQiCMS and want to call the contact name of *other sites* in the template of the current website,
contactLabels also providedsiteIdParameters to support this requirement:{% contact otherSitePerson with name="UserName" siteId="2" %} <p>友站联系人:{{ otherSitePerson }}</p>Here
siteId="2"Assuming you want to call the contact name of the site with ID 2. This provides the possibility of integrating resources and displaying content across sites.
Three, integrating the website structure: a practical code example
Now, let's integrate these knowledge points and envision a typical scenario where the contact name is displayed at the bottom of the website page:
<footer class="site-footer">
<div class="container">
<div class="contact-info">
{% contact mainContactPerson with name="UserName" %}
{% if mainContactPerson %} {# 建议:使用条件判断,确保内容存在才显示 #}
<p>网站运营:{{ mainContactPerson }}</p>
{% endif %}
{% endcontact %}
{% contact phoneNumber with name="Cellphone" %}
{% if phoneNumber %}
<p>联系电话:{{ phoneNumber }}</p>
{% endif %}
{% endcontact %}
{% contact supportName with name="SupportContact" %} {# 假设您自定义了一个 SupportContact 字段 #}
{% if supportName %}
<p>技术支持:{{ supportName }}</p>
{% endif %}
{% endcontact %}
<p>© {% now "2006" %} 所有权利保留.</p>
</div>
</div>
</footer>
In this example, we elegantly display the website's contact information, phone number, even a custom 'technical support' contact. By{% if %}Condition judgment ensures that when some fields are not filled in the background, the front-end will not appear with empty tags or unnecessary text, thus enhancing the robustness and user experience of the website.{% now "2006" %}The label dynamically retrieves the current year to ensure that the copyright information is always up to date.
Summary
Displaying the website contact name in AnQiCMS is a simple and practical operation. Through the background "Contact Information Settings" flexibly configure the data source, and combinecontactThe powerful calling ability of template tags allows you to easily present this important information anywhere on the website.Whether it is a default field or a custom parameter, AnQiCMS provides a unified and efficient solution to help your website operation become more professional and convenient.
Frequently Asked Questions (FAQ)
Q1: Why is the contact name I filled in the "Contact Information Settings" on the backend not displayed on the website front end?A1: There may be several reasons. First, make sure you are using the template correctly.{% contact with name="UserName" %}Tag to call. Next, after saving the background settings, it may be necessary to clear the AnQiCMS system cache to see the updates on the front end. You can find the "Update Cache" option in the upper right corner of the background management interface to perform the operation.Finally, check if your template file is loaded correctly, or if it is hidden by other conditional logic.
Q2: Besides the contact name, what other contact information can I display in the template?A2:contactThe label can call all the information configured in the background "Contact Information Settings". In addition,UserName(Contact Name) you can also useCellphone(Contact Phone),Address(Contact Address),Email(Contact Email),Wechat(WeChat ID),Qrcode(WeChat QR code image link) and preset fields. In addition, any contact information fields customized in the background can be called through their corresponding parameter names (for exampleSalesContact) to call.
Q3: If my website needs to display multiple different roles of contacts (such as sales and customer service), can AnQiCMS achieve this?A3: Yes, AnQiCMS can be realized through custom contact method parameters. You can set it in the background "Contact Information Settings"