As an experienced website operator proficient in AnQiCMS, I know that efficiently and accurately obtaining and displaying global configuration information in templates is crucial for website maintenance, brand consistency, and user experience.AnQiCMS provides intuitive and powerful template tags that can easily achieve this goal.
In AnQiCMS template, retrieve and display the global configuration information of the website, such as the website name, Logo, filing number, etc., mainly relies on the built-in system.systemThe tag is specifically designed to extract various core website information configured in the background "Global Settings", ensuring that the website maintains a unified brand image and operational information on any page.
Core Label: System
systemTags are the key to accessing the AnQiCMS global configuration data. Its basic usage method is{% system 变量名称 with name="字段名称" %}. Among them,变量名称Is an optional parameter, used to assign the obtained value to a temporary variable so that it can be referenced multiple times in the template or used for logical judgment. If omitted变量名称, the tag will directly output the value of the field.nameThe parameter is required, specifying the specific global configuration field you want to retrieve.
The AnQiCMS backend "Global Settings" module (located under "Backend Settings" -> "Global Settings") allows you to define various basic information about the website. This information can be directly accessed throughsystemThe tag is called in the template.
Website Name (SiteName)
The website name is the identifier of the website, which is usually displayed in the browser title bar, header, and other places. Throughsystemthe tag, you can easily get this information:
<title>{% system with name="SiteName" %} - 您的页面标题</title>
<h1>欢迎来到 {% system with name="SiteName" %}</h1>
You can also choose to assign it to a variable so that it can be used more flexibly in the template:
{% system siteName with name="SiteName" %}
<header>
<h1>{{ siteName }}</h1>
</header>
Website Logo (SiteLogo)
The website logo is the core element of brand visual identification. In AnQiCMS, the path of the uploaded logo image can be obtained throughsystemtags and applied to<img>in the tag.
<a href="/">
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
</a>
To enhance user experience and SEO effects, it is recommended to<img>labels to use simultaneouslyaltAttribute, and set its value to the website name.
{% system siteLogo with name="SiteLogo" %}
{% system siteName with name="SiteName" %}
<a href="/">
<img src="{{ siteLogo }}" alt="{{ siteName }}" />
</a>
Website record number (SiteIcp)
Websites operating in mainland China usually need to be registered. AnQiCMS provides a configuration item for the registration number in the background, throughsystemTags can be displayed at the bottom of the website or in other required positions.
<footer>
<p>备案号:<a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a></p>
</footer>
Copyright Information (SiteCopyright)
The copyright information of the website is usually displayed in the footer to declare the ownership of the website content.
<footer>
<p>{% system with name="SiteCopyright" %} © {% now "2006" %} All Rights Reserved.</p>
</footer>
Here we also combined with{% now "2006" %}tags to dynamically obtain the current year, keeping the copyright information up to date.
Home page address (BaseUrl)
It is very useful to get the root URL of the website when building absolute links or performing page jumps.
<a href="{% system with name="BaseUrl" %}">返回首页</a>
Template static file address (TemplateUrl)
For easy reference to static resources (such as CSS, JavaScript, images, etc.) in the template directory, AnQiCMS providesTemplateUrlThe field points to the root path of the static resources of the current active template.
<link rel="stylesheet" href="{% system with name="TemplateUrl" %}/css/style.css">
<script src="{% system with name="TemplateUrl" %}/js/main.js"></script>
Custom parameter
In addition to the built-in global configuration items, AnQiCMS also supports adding custom parameters in the background "Global Settings".These custom parameters can be used to store any information you wish to call globally on the website, such as customer service phone numbers, company fax numbers, custom social media links, and so on.
Assuming you have added a custom parameter named "CustomerServicePhone" with a value of "400-123-4567" in the background, you can call it in the template like this:
<div>客服电话:{% system with name="CustomerServicePhone" %}</div>
This will greatly enhance the flexibility and maintainability of the template, avoid hard coding, and allow operators to directly update information through the back-end interface.
Application scenarios and **practice
These global configuration information is usually placed in the common area of the website, such as the header (header), footer (footer), or sidebar (sidebar), etc., common template fragments. By using inbase.htmlorpartial/header.html/partial/footer.htmlIntegrating these tags into the files ensures that all relevant information on the entire website can be automatically synchronized after updating the background settings, without the need to manually modify each page.
For example, a typicalheader.htmlThe file may contain the following structure:
<!DOCTYPE html>
<html lang="{% system with name='Language' %}">
<head>
<meta charset="UTF-8">
<title>{% tdk with name="Title" siteName=true %}</title>
<meta name="keywords" content="{% tdk with name="Keywords" %}">
<meta name="description" content="{% tdk with name="Description" %}">
<link rel="stylesheet" href="{% system with name="TemplateUrl" %}/css/style.css">
<link rel="icon" href="{% system with name="SiteLogo" %}" type="image/x-icon">
</head>
<body>
<header>
<div class="logo-area">
<a href="{% system with name="BaseUrl" %}">
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
</a>
</div>
<nav>
{# 导航栏标签 {% navList ... %} 通常会放在这里 #}
</nav>
</header>
This modular reference method, combined with the powerful global configuration management function of AnQiCMS, makes website content creation and operation more convenient and efficient.
Frequently Asked Questions
What should I do if I updated the website name or Logo on the AnQiCMS backend, but the front-end page did not take effect immediately?
This is usually due to system caching. AnQiCMS caches some data to improve website access speed.After changing the configuration in the background, you need to go to the background's "Update Cache" feature and click to clear the system cache.After cleaning is completed, the front-end page will display the latest configuration information.If it still does not work, try clearing your browser cache or accessing in incognito mode.
How can I reference the global configuration information of a specific site in the AnQiCMS deployment across multiple sites?
AnQiCMS'systemTag supportsiteIdParameter. If you have deployed multiple sites and want to display global information from other sites in the template of the current site (for example, the main site's Logo), you can explicitly specifysiteIdFor example,{% system with name="SiteLogo" siteId="1" %}You will obtain the logo of the site with ID 1. Please note,siteIdIt is the unique ID assigned to each site in the multi-site management of AnQiCMS backend.
Can I passsystemTag to get the current status of the website (for example, whether it is closed) or the current language?
Yes,systemTag can get this information. You can{% system with name="SiteCloseTips" %}Get the closure notice and proceed by{% system with name="Language" %}Get the language code of the current site. This information is very useful when rendering conditions based on website status or language, such as displaying a maintenance page, or setting according to the language code.<html>label'slangProperty.