How to retrieve and display the contact, phone number, address, and other information configured in the background?

Calendar 👁️ 74

It is crucial to clearly display a company's contact information in website operations to establish customer trust and promote communication.Whether it is the contact name, phone number, office address, or social media account, this information needs to be easily accessible to users in a prominent position on the website.Aqie CMS provides a convenient solution for this, allowing you to flexibly manage and display this key information without writing complex code.

Configure your contact information in the background

The AnqiCMS backend design is aimed at making it easy for you to manage your website content, including your contact information.To configure this information, you can log in to the background management interface, find the "Contact Information Settings" option under the "Background Settings" menu.Here, you will see a series of preset fields, such as "Contact Person", "Contact Phone", "Contact Address", "Contact Email", as well as "WeChat ID" and "WeChat QR Code".You just need to fill in your information in the corresponding input box.

It is worth mentioning that if the preset fields cannot meet your business needs, AnQi CMS also provides a "custom parameter setting" function.You can add custom fields as needed, such as WhatsApp account, Facebook homepage link.These custom field names can be freely set, and the system will automatically convert letters to camel case for easy calling in the front-end template.Fill in the "Parameter name" and "Parameter value", and add a "remark" for future identification, and your custom contact information is set up.

Retrieve and display contact information in the template

After configuring the contact information, the next step is to display them on the website front-end. Anqi CMS provides a special template tag for obtaining contact information—contact. This label is very intuitive and easy to use.

Basic usage is like this:{% contact 变量名称 with name="字段名称" %}

The "field name" is the name of the items you fill in the "Contact Information Settings" backend (such asUserName/Cellphone/AddressWait). If you do not specify a 'variable name', the label will directly output the value of the field. If you specify a 'variable name', for example{% contact myPhone with name="Cellphone" %}, then you can use it in subsequent code.{{myPhone}}to refer to this value

Here are some common ways to obtain fields:

  • Contact name: <span>联系人:{% contact with name="UserName" %}</span>
  • Contact Phone: <span>联系电话:<a href="tel:{% contact with name="Cellphone" %}" rel="nofollow">{% contact with name="Cellphone" %}</a></span>
  • Contact address: <span>联系地址:{% contact with name="Address" %}</span>
  • Contact Email: <span>联系邮箱:<a href="mailto:{% contact with name="Email" %}">{% contact with name="Email" %}</a></span>
  • WeChat account: <span>微信号:{% contact with name="Wechat" %}</span>
  • WeChat QR Code: <span><img src="{% contact with name="Qrcode" %}" alt="微信二维码" /></span>Please note that when obtaining image URLs, such as WeChat QR codes, they are often embedded.<img>label'ssrcthe attribute.

For the custom contact information you add in the background, for example, if you create a custom parameter named "WhatsApp", you can also get its value bycontactusing the tag:<span>WhatsApp:{% contact contactWhatsApp with name="WhatsApp" %}{{contactWhatsApp}}</span>In the above example, we first assigncontactthe value obtained from thecontactWhatsApplabel to a variable, and then output. If a custom field may not have content, you can also use conditional judgment in conjunction with it{% if contactWhatsApp %}Avoid displaying empty content.

Flexible application to all corners of the website.

In a website, contact information is usually found in the footer, "Contact Us" page, or sidebar, etc. To avoid writing the same code on each page, you can fully utilize the Anqi CMS template'sincludeFeature.

You can create a name calledpartial/footer.htmlThe file, place all contact information related template code in it. For example:

<div class="contact-info-block">
    <p>联系人:{% contact with name="UserName" %}</p>
    <p>电话:<a href="tel:{% contact with name="Cellphone" %}" rel="nofollow">{% contact with name="Cellphone" %}</a></p>
    <p>地址:{% contact with name="Address" %}</p>
    <p>邮箱:<a href="mailto:{% contact with name="Email" %}">{% contact with name="Email" %}</a></p>
    <p>微信:{% contact with name="Wechat" %}</p>
    {% set qrcodeUrl = "" %}
    {% contact qrcodeUrl with name="Qrcode" %}
    {% if qrcodeUrl %}
        <div>
            <img src="{{qrcodeUrl}}" alt="微信二维码" />
        </div>
    {% endif %}
    {% set whatsapp = "" %}
    {% contact whatsapp with name="WhatsApp" %}
    {% if whatsapp %}
        <p>WhatsApp:{{whatsapp}}</p>
    {% endif %}
</div>

Then in your main template file (such asbase.htmlorindex.html), simply include this section:{% include "partial/footer.html" %}

This way, when you need to update contact information, you just need to modify it in the background, and the front-end page will automatically update without changing any template code, greatly improving operational efficiency.

For users with multiple site needs

Related articles

How to call and format the display of the website filing number and copyright information in AnQi CMS templates?

During the operation of the website, the filing number and copyright information are indispensable elements, which not only concern the legality of the website but also reflect the professionalism of the website.For websites built using Anqi CMS, it is a very basic but important skill to flexibly call and format these information in the template.Luckyly, AnQi CMS provides a simple and powerful template tag system, making it extremely easy to call the website filing number and copyright information.Next, let's see how to achieve this goal in Anqi CMS templates.

2025-11-07

How to effectively display the site name and Logo configured in the AnQi CMS backend on the front-end page?

In website operation, the name and logo of the site are the cornerstone of the brand image, they are not only an important sign for visitors to identify the website, but also a key to conveying brand value and building trust.AnQiCMS is a powerful content management system that fully considers this requirement, providing an intuitive and convenient way to configure and display these core brand elements.Next, let's discuss how to effectively use the site name and Logo configured in AnQiCMS to bring vitality to the frontend page.

2025-11-07

How to use Sitemap and Robots.txt to improve the display effect of content in search engines?

In the world of digital marketing, it is crucial to ensure that your website content is discovered by search engines and displayed well.Sitemap (site map) and Robots.txt files are two important tools for communication between websites and search engines.They are like navigation maps and behavioral guidelines prepared for search engine crawlers. Reasonably utilizing them can significantly improve the performance of your AnQiCMS website in search results.What is a Sitemap?

2025-11-07

How can AnQi CMS improve the visibility of a website in search engines through advanced SEO tools?

In today's highly competitive online environment, whether a website can stand out in search engines is directly related to the dissemination effect and commercial value of its content.Search engine optimization (SEO) is no longer just a cherry on top, but the cornerstone of website operation.It is crucial for many small and medium-sized enterprises and content operation teams to choose a content management system (CMS) that deeply supports SEO.

2025-11-07

How to customize contact information parameters in AnqiCMS and call them to display in the template?

It is crucial to maintain smooth communication with users in website operation.In addition to traditional contact methods such as phone and email, we often need to display more personalized social media or instant messaging information.AnqiCMS provides a very flexible contact information management module that allows you to easily customize and flexibly display this information at any location on the website.Next, we will divide it into two main steps to explain in detail how to customize contact information parameters in AnqiCMS and call them to display in the template.### One, in AnqiCMS

2025-11-07

How to dynamically display Title, Keywords, and Description on the homepage to optimize SEO?

It is the first step in building a successful website to make it search engine friendly.And Title (title), Keywords (keywords), and Description (description) - usually abbreviated as TDK - are the core elements of a website's dialogue with search engines.They not only tell search engines about the content of your page, but also directly affect whether users click on your website in the search results.AnQi CMS knows this, and therefore built-in powerful TDK management features, allowing you to easily achieve the dynamic display and optimization of TDK.

2025-11-07

How to control whether the website name suffix is displayed in the homepage title TDK tag?

If you are using AnQiCMS to build or manage your website, you may encounter a common and important issue: how to finely control whether the website name is displayed as a suffix in the `<title>` tag on the home page.This not only concerns the display effect of the website in search engine results, but also directly affects users' perception of the brand.The AnQi CMS, as a content management system that focuses on SEO optimization and flexibility, provides simple and powerful control capabilities in this aspect.First, let's clarify what is meant by the "website name suffix" mentioned here

2025-11-07

How to create and manage a website navigation menu and implement the display of secondary navigation?

The website's navigation menu, like the skeleton and landmark of the website, guides visitors to quickly find the information they need, and is the core of user experience and website information architecture.A clear and intuitive navigation system not only enhances user satisfaction, but is also crucial for search engine optimization (SEO).AnQiCMS was designed with this in mind from the outset, providing a flexible and easy-to-operate navigation menu management function, allowing website operators to easily build and maintain the navigation system of the website.

2025-11-07