How to flexibly call the system global configuration information for display in the website template?

Calendar 👁️ 89

Flexibly calling the system global configuration information in the website template is a key step in building a dynamic and easy-to-maintain website.AnQiCMS (AnQiCMS) is fully aware of this need and therefore provided powerful and intuitive template tags from the beginning, allowing users to easily display preset system-level data, contact information, and even customized information at any location on the page.

The AnQi CMS template system uses a syntax similar to the Django template engine, where variables are typically enclosed in double curly braces{{ 变量名 }}Define, and various operations and tags are represented by single curly braces and percentages{% 标签名 %}To implement. This design ensures that the template code is clear and easy to read. To call the global configuration information, we mainly usesystem/contactandtdkthese three core tags, as well as one for completely custom content.diy.

Invoke system-level basic configuration information(systemtags)

When we need to display the website name, Logo, filing number and other basic information in the page header, footer or any general area of the website,systemThe tag is our powerful assistant. This tag can obtain preset data from the background "global settings".

For example, to display the name of the website, we can write it like this in the template:

<title>{{ title }} - {% system with name="SiteName" %}</title>

This code will first retrieve the title of the current page, then append it to the website name set in the background. If you want to retrieve the logo image and display it, you can do it like this:

<a href="{% system with name="BaseUrl" %}">
    <img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
</a>

Here we not only display the Logo image, but also wrap it into a link pointing to the homepage address of the website. Similarly, the website's filing number (SiteIcp) and copyright information (SiteCopyright) Can be easily called:

<p>
    <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a>
     {% system with name="SiteCopyright" %}
</p>

Furthermore,systemThe tag can also get the basic URL of the website:BaseUrl) Mobile end URL:MobileUrl) Static file path of the current template:TemplateUrl) and site language (Language) and information for resource reference and multilingual adaptation. For example, when referencing template CSS files:

<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">

It is worth mentioning that if you have enabled the multi-site management feature in the Anqi CMS backend and want to call data from other sites in the current template, you can do so bysiteIdSpecify the parameter, for example{% system with name="SiteName" siteId="2" %}.

Contact information of the website (contacttags)

Contact information of the website, such as phone number, address, email, social media links, etc., is often need to be managed uniformly and displayed on multiple pages.contactTags are born for this, it directly gets data from the "Contact Information Settings" in the background.

To display the contact phone number of the website, we can do it like this:

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

Or contact email:

<div>邮箱:<a href="mailto:{% contact with name="Email" %}">{% contact with name="Email" %}</a></div>

If the background is configured with a WeChat QR code, the display is also very simple:

<div>
    <img src="{% contact with name="Qrcode" %}" alt="微信二维码" />
</div>

contactTags not only support these built-in fields, but also allow users to customize parameters in the background "Contact Information Settings", such as adding a "WhatsApp contact". Once defined, it can be called like a built-in field:

<div>WhatsApp:{% contact with name="WhatsApp" %}</div>

Control the page's SEO meta information (tdktags)

SEO (Search Engine Optimization) is crucial for the visibility of a website. The page'stitle/keywordsanddescriptionis an indispensable part of it.}tdkTags are specifically used to obtain this meta information and support flexible display methods. This information also comes from the "Homepage TDK settings" or the SEO configuration of each content detail page.

In<head>Region, we usually use it like thistdkTags:

<title>{% tdk with name="Title" siteName=true sep="_" %}</title>
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">

here,Titlelabel'ssiteName=trueIt will automatically add the website name to the end of the page title,sep="_"It defines the separator between the title and the website name.

For the canonical URL, this is an important SEO**practice to avoid duplicate content issues.tdkTags can also retrieve it, but we usually check if it exists first:

{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}

This ensures that standard link tags are only output when necessary.

Flexible customization of global variables (diyTags and custom parameters

In addition to the above standardized configuration information, we may sometimes need to define some completely customizable global variables in the background, such as the link of a marketing campaign, some notification text, etc. Anqi CMS provides two ways to achieve this customization:

  1. InsystemorcontactAdd custom parameters in the label:Just like wecontactthe tag withWhatsAppAdd custom parameters (for example, in the "Global Function Settings" or "Contact Information Settings"):HelpUrlThen go through the correspondingsystemorcontacttags toname="HelpUrl"Call in the form of.

    <div>帮助页面:{% system with name="HelpUrl" %}</div>
    
  2. UsediyTags: diyTag is a more general custom content tag that directly corresponds to any globally defined field in the background.

    For example, in the background, we defined a field namedAuthorThe parameter, it can be obtained like this in the template:

    <div>网站作者:{% diy with name="Author" %}</div>
    

This flexible custom function allows us to expand and call various personalized global configurations according to the specific needs of the website.

By using these built-in template tags, Anqi CMS greatly simplifies the process of calling global configuration information.We just need to set the corresponding values in the background, and then use concise tag syntax in the template to achieve dynamic display and efficient management of website content.This not only improves the development efficiency, but also makes the website's post-maintenance and content updates more convenient.


Frequently Asked Questions (FAQ)

  1. **Ask: If I modify a global configuration in the background, but the front page

Related articles

How does AnQiCMS improve the loading speed and display experience of website content through static caching?

In today's fast-paced digital world, the loading speed of websites and user experience are crucial.A fast-reacting website can not only effectively retain visitors but also improve search engine rankings and bring more exposure to the content.AnQiCMS, as an enterprise-level content management system developed based on the Go language, has always regarded high performance as one of its core goals from its initial design, and has significantly improved the speed of website content loading and display experience through this key technology of static caching.Static caching, in simple terms, is the process of pre-generating static HTML files for a website's dynamic content

2025-11-08

How to configure resource storage and backup to ensure the security and recoverability of website content?

In daily website operations, the security and recoverability of content are of great importance.Imagine if your website data suddenly disappeared, or if important images failed to display, how much trouble it would cause for operations.AnQiCMS (AnQiCMS) is an efficient content management system that provides many functions to help us manage website resources properly and ensure quick recovery in case of emergencies.This article will delve into how to configure the resource storage and backup mechanism of Anqi CMS to maintain the continuous stable operation of the website.### One

2025-11-08

How to use the scheduled publishing feature to control articles to be automatically displayed at a future time?

In content operation, the rhythm and timing of content release are often the key factors determining its effectiveness.Imagine that you have carefully prepared a series of contents, hoping that they will appear on the website at a specific time, such as 9 am every morning, or automatically go online before the upcoming festival activities.Manual operation is not only inefficient but also prone to errors. AnQiCMS (AnQiCMS) understands this need and provides a convenient scheduling publishing function, allowing you to easily plan future content and achieve automated operations.Schedule release

2025-11-08

How to optimize website content display strategy through traffic statistics?

In the wave of today's digital marketing, a website is no longer just a pile of content, but also a bridge for interaction with users.Every click, stay, and even departure of each visitor contains valuable information.How to transform these original data into practical insights, thereby optimizing the website content strategy, which is the key to improving operational efficiency and website value.AnQiCMS as a comprehensive content management system, its built-in traffic statistics tool is an important tool for us to achieve this goal.The traffic statistics and crawler monitoring function provided by AnQiCMS is not just a pile of numerical reports, it is a mirror

2025-11-08

How to dynamically display contact information in website templates?

When operating a website, we often need to display the company's contact information, such as phone, email, address, and even social media links.The traditional way might be to hardcode this information directly in the template, but this means that every time the contact information changes, you need to modify the code, which is麻烦 and easy to make mistakes.AnQiCMS (AnQiCMS) provides a flexible and efficient solution that allows you to easily display and manage these contact methods in website templates.This means that once the contact information changes, you only need to update it once in the background

2025-11-08

How to set independent TDK (title, description, keywords) for the homepage of a website to optimize search results display?

How to make your website stand out among a vast amount of information and gain more exposure in website operation?In this case, Search Engine Optimization (SEO) plays a vital role, and the title (Title), description (Description), and keywords (Keywords), which we commonly refer to as TDK, are the cornerstone of SEO strategy.For users of AnQiCMS, setting up independent homepage TDK is not only simple and efficient, but also a key step in optimizing website search performance.Why is the TDK setting on the homepage crucial

2025-11-08

How to customize the website navigation menu to display multi-level content links?

During the process of building and operating a website, the navigation menu plays a crucial role.It is not only a guide for users to explore the content of the website, but also the key for search engines to understand the structure of the website.AnQiCMS (AnQiCMS) fully understands this point, therefore it provides a flexible and powerful navigation menu customization feature, allowing us to easily implement the display of multi-level content links, thereby optimizing user experience and enhancing the overall efficiency of the website.Next, we will together learn how to customize and manage the website navigation menu in Anqi CMS, and make it able to flexibly display multi-level content links.##

2025-11-08

How to filter and display content under specific models or categories on the document list page?

When managing website content, we often need to display specific types or themes of content on different list pages, such as article lists, product showcase pages, or detailed summaries of custom models.This not only concerns whether users can find the information they need efficiently, but also directly affects the overall layout and user experience of the website.Anqi CMS with its flexible content model and efficient system architecture provides us with powerful tools to accurately filter and personalize content display.### The Core of Content Organization: Models and Classification In AnQi CMS

2025-11-08