How does the `contact` tag dynamically display website contact information (phone, address, email, etc.)?

Calendar 👁️ 89

AnQiCMS provides a flexible and efficient way to manage various information on the website, among which the dynamic display of website contact information is achieved through its built-incontactTags can be easily implemented. This means you do not need to manually modify the code, and you can centrally manage information such as phone numbers, addresses, and email addresses in the background, and automatically update them to various pages of the website.

One, set the website contact information centrally in the background

To dynamically display contact information, you first need to enter this information into the Anqi CMS backend. The operation path is very intuitive: after logging into the backend, navigate toBackend settingsThen select the menu.Contact information settings.

On this page, you will see a series of default settings, including:

  • ContactFor example, your name or company contact person.
  • Contact phone numberThe main contact phone number of the company.
  • Contact addressCompany detailed address:
  • Contact email: Used for customer communication email address.
  • WeChat ID: Convenient for customers to add WeChat friends.
  • WeChat QR code: Upload WeChat QR code image directly.

In addition to these commonly used contact methods, Anqi CMS also providesCustom settings parametersFunction. If you have any special contact information that you need to display, such as WhatsApp, Facebook homepage link, Twitter account, or any other information that needs to be dynamically displayed on the website, you can add it here.

When customizing parameters, you need to fill in:

  • Parameter NameThis is the identifier you call this information in the template. It is recommended to use English, and the system will automatically convert it to camel case.For example, if you enter "WhatsApp", when calling the template it isWhatsApp.
  • Parameter valueThis is the actual content to be displayed, such as your WhatsApp number or Facebook homepage URL.
  • NoteUsed to record the purpose of this custom parameter for easy management.

In this way, all contact information of the websites is centralized in the background. Whether it is to update the phone number or to change the email address, it only needs to be modified once in the background, and all the places calling this information on the website will be automatically updated.

Second, dynamically call the contact information in the website template

After completing the setting of the background contact information, the next step is to use it in the website front-end templatecontactLabel to dynamically display this information. The Anqi CMS template engine uses a syntax similar to Django, which is simple and clear in its calling method.

contactThe basic usage of tags is:{% contact 变量名称 with name="字段名称" %}.nameThe property is crucial, it needs to match the "parameter name" you set in the background or the default field name.变量名称It is optional, if you want to store the obtained value in a variable for subsequent processing, you can specify a variable name; otherwise, the label will output the content directly.

Here are some common contact methods and their correspondingcontactTag call example:

  1. Display contact phone numberIf you want to display the company's contact phone number in the footer or contact us page, you can usename="Cellphone":

    <p>联系电话:{% contact with name="Cellphone" %}</p>
    

    Or add the phone number to a clickable link:

    <p>电话咨询:<a href="tel:{% contact with name='Cellphone' %}" rel="nofollow">{% contact with name="Cellphone" %}</a></p>
    
  2. Display contact emailContact email is usually used byname="Email"And can be combined withmailto:An agreement, so that the user can send an email by clicking:

    <p>邮箱地址:<a href="mailto:{% contact with name='Email' %}">{% contact with name="Email" %}</a></p>
    
  3. Display contact address name="Address"Suitable for displaying the physical address of the company:

    <p>公司地址:{% contact with name="Address" %}</p>
    
  4. Display WeChat QR codeIf the WeChat QR code image is uploaded on the back-end, it can be used:name="Qrcode". Since it returns the image URL, it needs to be配合<img>the tag to use:

    <div class="wechat-qrcode">
        <img src="{% contact with name="Qrcode" %}" alt="微信二维码" />
        <p>扫码关注我们</p>
    </div>
    

    Please note, for page accessibility (SEO and visually impaired users), it is a good practice to addaltan attribute.

  5. Display custom contact informationSuppose you added a custom parameter namedWhatsAppThe parameter value is your WhatsApp number. You can call it like this in the template:

    <p>WhatsApp:<a href="https://wa.me/{% contact with name='WhatsApp' %}" target="_blank">{% contact with name="WhatsApp" %}</a></p>
    

    HereWhatsAppIt is the parameter name set in the background.

  6. Call in a multi-site environment.If your security CMS is deployed across multiple sites and you need to call the contact information of a specific site, you can usesiteIdparameters:

    <p>站点A电话:{% contact with name="Cellphone" siteId="1" %}</p>
    

    In most cases, if you do not need to call across sites, you can ignoresiteIdParameters, the system will automatically retrieve the contact information of the current site.

By these flexible calling methods, you can ensure that the contact information on the website is always up-to-date and consistent, greatly enhancing the efficiency of website operations and user experience.

Chapter 3, Summary

Of Security CMScontactTags are an indispensable tool in website content operation. They剥离 the core contact information from the code, achieving centralized management and dynamic display, making website updates and maintenance extremely simple.Whether it is a phone number, address, email, or various social media contact information, it can be easily displayed in front of users through simple backend settings and template tags, helping you build a professional, efficient, and easy-to-maintain website.

Frequently Asked Questions (FAQ)

  1. Ask: Why did I usecontactLabel, but the website front-end does not display any information?Answer: There are usually several reasons. First, please check if you have actually filled in the corresponding information in the "Background Settings" -> "Contact Information Settings" on the Anqi CMS backend.Secondly, please ensurecontactin the labelnameThe attribute value is exactly the same as the "parameter name" set in the background (including case). Finally, if the information contains images (such as WeChat QR codes), please ensure that the images have been successfully uploaded.

  2. Ask: Besides phone and email, what other contact information fields can I customize?Answer: The 'Contact Information Settings' page of Anqi CMS provides the 'Custom Settings Parameters' feature.You can add any field as per your requirement, such as WhatsApp number, Telegram ID, Facebook homepage link, LinkedIn personal page, Instagram account, etc.Please enter your 'parameter name' (suggested in English) and the corresponding 'parameter value', then use it in the template{% contact with name="您的参数名" %}can be called in this way.

  3. Question:contactCan the content returned by the tag be directly used as an attribute of an HTML tag? For example, ashref?Answer: Yes,contactThe tag returns only plain text strings (except for image URLs). Therefore, you can directly embed it in the attributes of HTML tags, for example<a href="tel:{% contact with name='Cellphone' %}">Or<img src="{% contact with name='Qrcode' %}" />To achieve functions such as making phone calls, sending emails, or displaying images.

Related articles

How to build a multi-level navigation menu using the `navList` tag and display it on the front end?

AnqiCMS provides powerful and flexible configuration options for website navigation, allowing you to easily build multi-level navigation menus and customize the display on the front-end website according to business needs.Whether it is a simple single-layer menu or a complex multi-level navigation with dropdown content, the `navList` tag can help you a lot. To implement multi-level navigation, we first need to complete the configuration of the navigation structure in the background management system, which lays the foundation for the display on the front end.

2025-11-07

How to dynamically generate the page Title, Keywords, and Description using the `tdk` tag to optimize SEO display?

In website operations, Search Engine Optimization (SEO) is a key link to improve website visibility and attract natural traffic.Among them, the page's `Title` (title), `Keywords` (keywords), and `Description` (description), abbreviated as TDK, are important signals for search engines to understand the content of the page and determine the ranking.An excellent TDK setting can make your website stand out in a sea of information.AnQiCMS (AnQiCMS) fully understands the importance of TDK and has integrated powerful TDK management functions into the system design from the very beginning

2025-11-07

How to get and display the title, content, and image of a single page using the `pageDetail` tag?

## AnQi CMS `pageDetail` tag: Easily obtain and display single page information Single pages (such as "About Us", "Contact Us", "Terms of Service", etc.) play an indispensable role in website content management.They usually carry stable, core information that does not need to be updated as frequently as articles or products.AnQi CMS provides an efficient and flexible tool for displaying this type of page - the `pageDetail` tag.Mastering the use of this tag will allow you to be proficient in template development, easily presenting beautifully designed single-page content

2025-11-07

How to get and display the title, description, thumbnail, and associated content of the `categoryDetail` tag?

Manage and display website content in Anqi CMS, the `categoryDetail` tag plays a crucial role.It is like the conductor of your website content display, able to accurately obtain and present all the detailed information of a specific category, whether it is the title, description, thumbnail, or deeper related content, it can help you a lot. ### The core function of the `categoryDetail` tag In simple terms, the mission of the `categoryDetail` tag is to obtain detailed data for a single category.

2025-11-07

How to generate breadcrumb navigation using the `breadcrumb` tag to enhance the user's understanding of the page hierarchy?

In complex website content structures, users sometimes feel lost, not knowing the position of the current page.At this time, an auxiliary navigation method called "Breadcrumb Navigation" is particularly important.It not only clearly displays the path from the home page to the current page, but also helps users quickly understand the hierarchical structure of the website, thereby improving the browsing experience.For websites built with AnQiCMS, the system-built `breadcrumb` tag is exactly the tool to generate this efficient navigation.

2025-11-07

How `prevArchive` and `nextArchive` tags display the link and title of the previous/next document?

When browsing website content, users often hope to be able to easily jump from the current page to related or adjacent articles.This kind of previous/next navigation can not only significantly improve user experience, but also play an active role in SEO, guiding search engine spiders to more deeply crawl website content.

2025-11-07

How does the `pagination` tag handle the pagination display logic for article lists and product lists?

How to efficiently display a large number of articles or products in a content management system without sacrificing user experience, this is often a challenge faced by website operators.AnQiCMS (AnQiCMS) provides powerful template tag features, among which the `pagination` tag is a powerful tool to solve this problem, allowing flexible handling of pagination logic for article lists and product lists, making your website content well-organized.

2025-11-07

How to manage and display document tags and associated document lists for `tagList` and `tagDataList` tags?

In content management, tags are an important bridge for connecting content, enhancing user experience, and optimizing search engine performance.AnQi CMS understands its importance, providing powerful tag management functions, and through the two core tags `tagList` and `tagDataList`, allowing content operators to flexibly display and manage document tags and their associated content. ### Tag: A Tool for Content Categorization and Discovery Tags in Anqi CMS are not just simple keywords; they are a refined way of organizing content.

2025-11-07