How to retrieve and display the contact information configured on the website backend (such as phone number, address, social media links)?

Calendar 👁️ 92

It is crucial to clearly and conveniently display a company's contact information in website operation, as it not only enhances customer trust but also serves as a direct way for users to obtain services and consult.AnQiCMS (AnQiCMS) is a powerful content management system that provides intuitive backend configuration options and flexible template calling mechanisms, allowing you to easily manage and display this information.

Next, we will explore how to configure and display your website contact information on AnQiCMS, including phone numbers, addresses, social media links, and more.


The first part: Configure contact information in the AnQiCMS background

AnQiCMS concentrates the management of basic website information in the "Background Settings" module, which includes the "Contact Information Settings".This is the entry point for you to centrally manage all external contact information.

1. Go to contact information settings

Log in to your AnQiCMS admin interface and then find it in the left navigation barBackend settingsand then click to expand, selectContact information settings. Enter this page and you will see a series of preset contact information fields.

2. Fill in the core contact information.

On the "Contact Information Settings" page, you can fill in the following default fields according to your actual situation:

  • Contact: For example, "Mr. Wang" or "Customer Service Team".
  • Contact phone numberCustomer service phone number or business consultation phone number.
  • Contact addressCompany's detailed address, convenient for customers to visit offline or mail.
  • Contact emailEmail address for receiving consultation inquiries.
  • WeChat IDIf your company uses WeChat for customer service, you can fill in the WeChat ID.
  • WeChat QR codeUpload your WeChat customer service QR code image for easy scanning by users.

In addition to the above common information, AnQiCMS also presets mainstream social media platform link fields such as QQ, WhatsApp, Facebook, Twitter, Tiktok, Pinterest, Linkedin, Instagram, Youtube, and so on.You can selectively fill in the links to these platforms based on your business needs and target customer group.

3. Add custom contact information (as needed)

If the default fields provided do not cover all your contact information needs, for example, if you want to add a link to a specific instant messaging tool or some uncommon social platform, AnQiCMS also supports custom addition.

Under the "Contact Information Settings" page, there is usually a “Custom settings parameters” area. Here, you can:

  • Parameter Name: Enter a distinctive English name, such asLineIdorTelegramLink. This parameter name will be the key identifier you use to call this information in the website template. The system will automatically convert it to camelCase (such aslineId), convenient for template calls.
  • Parameter valuePlease fill in the specific contact information, such as your Line ID or Telegram group link.
  • Note: Add a brief description for this custom field to help you or other administrators understand its purpose.

In this way, AnQiCMS ensures that all contact information on your website can be centrally managed in the background and can be flexibly expanded to meet the changing business needs.


Part Two: Retrieve and display contact information in the website template

After configuring the background information, the next step is to call and display these data in the front-end template of your website.AnQiCMS's template system adopts a syntax style similar to Django, obtaining background data through specific tags (Tag).

1. Core Tags:contact

In the template files of AnQiCMS (usually located/templateUnder the directory.htmlfile), you can usecontactTags to retrieve the various information you have configured in the "Contact Settings" on the backend.

contactThe basic usage of tags is:{% contact 变量名称 with name="字段名称" %}. Among them:

  • 变量名称: is optional, you can specify a variable name for the contact information obtained for use in subsequent code. If not specified, it willcontactThe label will output the value of the field directly.
  • nameThis is the most critical parameter, it needs to correspond to the field name you have configured in the background (default field or custom field "parameter name").

2. Display commonly used contact information

Let us understand how to display this information in a template through a specific code example:

  • Display contact phone number

    <p>联系电话:{% contact with name="Cellphone" %}</p>
    {# 结合tel:协议,用户点击可直接拨号 #}
    <p><a href="tel:{% contact with name="Cellphone" %}" rel="nofollow">拨打电话:{% contact with name="Cellphone" %}</a></p>
    
  • Display contact address

    <p>公司地址:{% contact with name="Address" %}</p>
    
  • Display contact email

    <p>业务邮箱:{% contact with name="Email" %}</p>
    {# 结合mailto:协议,用户点击可直接发送邮件 #}
    <p><a href="mailto:{% contact with name="Email" %}" rel="nofollow">发送邮件:{% contact with name="Email" %}</a></p>
    
  • Display WeChat ID

    <p>客服微信:{% contact with name="Wechat" %}</p>
    
  • Display WeChat QR codePlease note when you need to display an image link (such as a WeChat QR code)|safeFilter. This is because the AnQiCMS template system defaults to escaping output content to prevent cross-site scripting attacks (XSS).For HTML code or image URLs that need to be directly parsed,|safeThe filter ensures its correct display.

    {% contact wechatQrcode with name="Qrcode" %}
    {% if wechatQrcode %} {# 检查是否存在二维码图片URL #}
        <p>微信扫码:<img src="{{ wechatQrcode | safe }}" alt="微信二维码" style="width: 100px; height: 100px;"></p>
    {% endif %}
    
  • Display social media linksFor example, using Facebook, the calling method is similar for other social media platforms (such as Twitter, LinkedIn, Instagram, etc.), just need tonameReplace the parameter with the corresponding field name.

    {% contact facebookLink with name="Facebook" %}
    {% if facebookLink %}
        <p>关注我们:<a href="{{ facebookLink }}" target="_blank" rel="nofollow">Facebook</a></p>
    {% endif %}
    

3. Show custom contact information

For example, if you have added a custom contact method in the background,LineIdyou can also usecontacttag to call:

{% contact lineId with name="LineId" %}
{% if lineId %}
    <p>Line ID:<a href="https://line.me/ti/p/~{{ lineId }}" target="_blank" rel="nofollow">{{ lineId }}</a></p>
{% endif %}

Please note that for values like Line ID, if it is not a complete URL itself, you may need to manually construct a clickable link, as shown in the example above.

4. Optimize display experience

To ensure the cleanliness of the website interface and the user experience, it is recommended to add conditional judgments in the template, so that only when a contact method has a value is it displayed, avoiding blank or incomplete information:

`twig {# Comprehensive example: Display all available contact information #}

<h3>联系我们</h3>
{% contact userName with name="UserName" %}
{% if userName %}<p>联系人:{{ userName }}</p>{% endif %}

{% contact cellphone with name="Cellphone" %}
{% if cellphone %}<p>电话:<a href="tel:{{ cellphone }}" rel="nofollow">{{ cellphone }}</a></p>{% endif %}

{% contact address with name="Address" %}
{% if address %}<p>地址:{{ address }}</p>{% endif %}

{% contact email with name="Email" %}
{% if email %}<p>邮箱:<a href="mailto:{{ email }}" rel="nofollow">{{ email }}</a></p>{% endif %}

{% contact wechat with name="Wechat" %}
{% if wechat %}<p>微信:{{ wechat }}</p>{% endif %}

{% contact wechatQrcode with name

Related articles

How to create and display custom single-page content (such as About Us, Contact Information)?

In website operations, content such as 'About Us', 'Contact Information', and 'Privacy Policy' is usually displayed in the form of independent pages. This content is relatively fixed and plays an important role in the website structure.AnQiCMS (AnQiCMS) provides an intuitive and powerful set of features for creating and managing these custom single-page applications, allowing you to easily publish and update without writing code. ### Create Custom Single Page Content Creating a single page in Anqi CMS is a simple and direct process.Firstly, you need to log in to the back-end management interface. 1. **Enter the page management

2025-11-08

How to add and display dynamic breadcrumb navigation on a webpage?

In modern web design, breadcrumb navigation plays a crucial role.It is like a 'footprint' of the user on the website, clearly showing the position of the current page in the overall website structure, making it easy for visitors to understand, thereby greatly enhancing the usability and user experience of the website.At the same time, a reasonably set breadcrumb navigation also helps search engines better understand the structure of the website, which is very beneficial for SEO optimization.For users who use AnQiCMS to manage websites

2025-11-08

How to precisely control the display content, level, and selected status of a website navigation menu?

Website navigation, like a signpost of a website, a clear and intuitive navigation system can greatly enhance the user experience and help visitors quickly find the information they need.At the same time, a good navigation structure is also crucial for search engines to understand the hierarchy of website content, to effectively crawl and rank.In AnQi CMS, we can flexibly and accurately control the display content, level, and selected status of the website navigation, making it both beautiful and practical.

2025-11-08

How to display the global TDK (Title, Keywords, Description) information of the website?

## Optimizing Website Front: Display and Application of TDK Information in AnQi CMS In website operation, TDK (Title, Keywords, Description) is an indispensable basic element for Search Engine Optimization (SEO).They are like the 'business card' of a website, directly telling search engines about the theme, core content, and most important keywords of your page, thereby affecting the ranking and click-through rate in search results.

2025-11-08

How to get and display the current year in a template for dynamic content such as copyright information?

When operating a website, we often need to display the current year in the footer copyright statement, for example, “© 2023 All Rights Reserved.”. With the passage of time, this year needs to be updated annually, and if manually modified, it is undoubtedly a repetitive and easily overlooked task.AnQi CMS fully considers this common demand and provides a very intuitive and powerful template tag that allows you to easily realize the dynamic display of years, keeping your website's copyright information always up to date.###

2025-11-08

How can AnQi CMS protect the copyright of original content through anti-crawling and watermark features when displayed?

On a day when digital content is increasingly abundant, the value of original content is self-evident, serving as the cornerstone for attracting users and building brand images on websites.However, the issues of content theft and malicious collection that follow also make countless creators and operators headache.Hardly written articles, carefully designed images, may be borrowed by others in a moment, even copied and pasted directly, which not only severely打击s the original enthusiasm, but also actually harms the intellectual property rights.For website operators, original content is the core competitiveness of the website.

2025-11-08

How to define and temporarily store variables in a template for easy content display and reuse?

When building a website, we often encounter situations where we need to repeat certain information or adjust content flexibly according to different contexts.If each time is hard-coded, it is not only inefficient but also quite麻烦 to maintain later.AnQiCMS (AnQiCMS) fully understands this, its template system provides various flexible ways to define and temporarily store variables in templates, thus achieving convenient display and efficient reuse of content.Why do you need to define and store variables in templates?

2025-11-08

How to determine whether the current item is the first or last in a looped article list so that special styles can be displayed?

In website content management, it is often encountered that there is a need: we hope that the first or last element of the article list, product list, or other data list can have special styles, such as the first article title being particularly prominent, or the last product detail not having a bottom separator line.This not only helps to highlight the key points, but also makes the visual effect of the page more hierarchical.AnQiCMS (AnQiCMS) powerful template engine provides us with a simple and efficient way to meet these customization needs.In Anqi CMS template system, we usually use `{% for ...

2025-11-08