In AnQiCMS template, elegantly display the website contact name: A guide for experts
Today, with the increasing popularity of digital marketing, a website is not only a platform for displaying information, but also a bridge for enterprises to establish trust and communication with users.An 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 authenticity and responsible attitude.For an enterprise-level content management system like AnQiCMS, how to efficiently and flexibly display these key information in templates is a core skill that website operators need to master.
AnQiCMS as an efficient content management system developed based on the Go language, has fully considered the customizability and ease of use of content from the very beginning.It deeply understands the needs of small and medium-sized enterprises and content operation teams for the flexibility of information display, and therefore provides strong support in template tags and backend configuration.Today, let's delve into how to accurately display the contact name of the website in AnQiCMS templates.
1. Back-end configuration of the contact name: The source of data
Any front-end display content cannot be separated from the careful configuration of the back-end.In AnQiCMS, the setting of the contact name is located in a location that is intuitive and easy to operate, which reflects its design philosophy of 'lightweight and efficient'.
You can navigate to the AnQiCMS backend by accessing,“Backend Settings”then select“Contact Information Settings”.In 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.
SalesContactfield, and enter "Manager Zhang". This design greatly enhances the flexibility of content operations.
English of auto template calling method: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 of the background settings, we mainly rely on a namedcontactThis is a dedicated template tag.
The design of this tag is originally intended to facilitate website operators in calling all data related to 'Contact Information 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
UserName: In the "Contact Information Settings", the "Contact" field we fill in is the internal identifier in the template.UserName. Therefore, if you want to display this contact name directly in the template, you can use it in this waycontactTags:<div>网站联系人:{% contact with name="UserName" %}</div>The code will directly output the content you filled in the "Contact" field under "Contact Information Settings" in the background.
Call through variable names to enhance readability and reusability: In order to make the template code more readable and convenient for multiple references to the same data within the same template area, you can
contactLabel the value obtained from the tag and assign it to a variable. For example, you can assign the contact name to a variable namedsiteContactPersona variable:{% contact siteContactPerson with name="UserName" %} <p>尊敬的访客,欢迎联系:{{ siteContactPerson }}</p>This is,
{{ siteContactPerson }}you can use{% contact %}and{% endcontact %}labels can be reused between them without needing to call them againcontactLabel.Call custom contact method fieldAs mentioned before, AnQiCMS allows you to add custom contact parameters in the background. For example, you have created a custom contact parameter named
SalesContactThe custom parameter. So, in the template, you can call this custom field in the same way as the preset field, 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.
Accurate calling in a multi-site environment: AnQiCMS的一个强大特性是支持多站点管理。如果您正在运营多个网站,并通过AnQiCMS统一管理,并且希望在当前网站的模板中调用*其他站点*的联系人姓名,
contacttags also providesiteIdParameters are provided to support this requirement:{% contact otherSitePerson with name="UserName" siteId="2" %} <p>友站联系人:{{ otherSitePerson }}</p>Here are the
siteId="2"Suppose you want to call the contact name of the site with ID 2. This provides the possibility of resource integration and content display across sites.
三、Incorporate into website structure: A practical code example
Now, let's integrate these knowledge points and imagine a typical scenario where the contact name is displayed in the footer of a 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 contact information, phone number, and even a custom 'Technical Support' contact.{% if %}Condition judgment ensures that the front-end will not display empty tags or unnecessary text when some fields are not filled in on the back-end, thereby enhancing the robustness and user experience of the website.{% now "2006" %}Labels are dynamically retrieved based on the current year to ensure that copyright information remains up-to-date.
Summary
In AnQiCMS, displaying the website contact name is a simple and practical operation. Configure the data source flexibly through the "Contact Information Settings" backend, and then combinecontactThe powerful call ability of template tags, you can easily display this important information at any corner of the website.Whether it is a default field or a custom parameter, AnQiCMS provides a unified and efficient solution to help your website operate more professionally and conveniently.
Common Questions (FAQ)
Q1: I filled in the contact name in the "Contact Information Settings" on the backend, why isn't it showing on the website front end?A1: There may be several reasons. First, please make sure you have used it correctly in the template.{% contact with name="UserName" %}Label 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 conditions.
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 "Contact Information Settings" on the backend. In addition toUserName(Contact Name),Cellphone(Contact Phone),Address(Contact Address),Email(Email Contact)、Wechat(WeChat ID)、Qrcode(WeChat QR code image link) and other preset fields. In addition, any contact information fields you customize in the background can be called by their corresponding parameter names (for exampleSalesContact)
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 implemented through custom contact method parameters. You can set it in the "Contact Information Settings" in the background