It is crucial to maintain brand consistency and the accuracy of information in website operation.AnQi CMS is an efficient content management system that provides us with a convenient way to manage and display these core information.systemLabel, easily obtain and display the global information of the website in the website template, such as the website name, Logo, and filing number.
UnderstandingsystemLabel: Extractor of website information.
In the template system of Anqi CMS,system
These global information is usually configured in the "Global Settings" of AnQi CMS.You can log in to the backend, find the 'Backend Settings' under the left navigation bar, and here you can find options such as website name, Logo image upload, filling in the filing number, and more.systemTags can be updated in real time.
How to usesystemTags retrieve information
systemThe usage method of tags is very intuitive, its basic syntax is{% system 变量名称 with name="字段名称" %}.
name="字段名称": This is the most critical part, it tellssystemLabel which specific global information you want to get. For example, to get the website name, the field name isSiteName; to get the website logo, it isSiteLogo; to get the filing number, it isSiteIcp.变量名称(Optional): You can choose to assign the obtained value to a temporary variable so that you can refer to it multiple times in the subsequent part of the template or perform more complex logical processing.If the value is not assigned to a variable, the label will directly output the value of the field.siteId(Optional): For an Aqin CMS instance that has enabled multi-site management, if you need to display global information of other sites in the template of the current site, you cansiteIdThe parameter specifies the target site's ID. Usually, we only need to retrieve the global information of the current site, so this parameter can be omitted.
Next, we will go through several common examples to see how to apply them in actual templatessystem.
1. Display the website name
The website name usually appears on the page.<title>In the tag, as well as in the navigation bar or footer, etc., it is one of the most important identifiers of a website.
On the page<head>Area:
<title>{% system with name="SiteName" %} - 您的网站</title>
If you want to add the website name to the title,tdkTags provide a more convenient way, but if it is simply to display the name of the website,systemtags are also applicable.
in the content area of the page, such as the top navigation bar or footer:
<h1>欢迎来到 {% system with name="SiteName" %}</h1>
Or, first assign the website name to a variable and then use it:
{% system siteName with name="SiteName" %}
<h1>{% if siteName %}{{ siteName }}{% else %}默认网站名称{% endif %}</h1>
The benefit of doing this is that it can provide a fallback text when the variable does not exist.
2. Display the website logo
The website logo is the visual core of the brand, usually located at the header, used to strengthen the brand image.
First, upload your website Logo image in the background "Global Feature Settings". Once uploaded, you can refer to it like this in the template:
<a href="/">
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
</a>
Here, we not only get the path of the Logo image, but also ingeniously utilizesystemthe tag to obtain the website name as the imagealtattribute value, which is very helpful for SEO and accessibility.
3. Display the website filing number
Websites operating in mainland China must have a filing number, which is an indispensable piece of information and is usually displayed in the footer of the website. Anqi CMS also providesSiteIcpField to manage this information.
<p>
<a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">
{% system with name="SiteIcp" %}
</a>
</p>
This code will obtain the filing number and place it in a link leading to the MIIT filing inquiry website, in compliance with national regulations.
Other commonly used global information
In addition to the aforementioned three items,systemthe tag can also obtain other useful global information:
- Copyright content (
SiteCopyright): Usually used for copyright statements in the footer.<p>{% system with name="SiteCopyright" %}</p> - The home page address (
BaseUrl)In some cases, it is necessary to dynamically generate links to ensure they point to the root directory of the website.<link rel="canonical" href="{% system with name="BaseUrl" %}" /> - Static file address of the template (
TemplateUrl): If you need to reference CSS, JS, or other resources in the current template directory, you can use this field to build the correct path.<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
Tips in practice
While usingsystemWhen labeling, it is recommended to place these global information in the public template file of the website (such aspartial/header.htmlorpartial/footer.htmlIf your template adopts this structureThis way, when you modify the global settings on the backend, all pages that reference these public files can be automatically updated without manually modifying each page, greatly improving maintenance efficiency.
Summary
systemThe tag is a basic and powerful tool in the development of Anqi CMS templates, which decouples the global configuration of the website from the front-end display, allowing content operators to focus on backend settings without touching the code. By using it flexiblysystemLabel, we can easily build a unified, professional and easy-to-manage website.
Frequently Asked Questions (FAQ)
Q1: Besides the website name, Logo and filing number,systemWhat global information can the label obtain?A1: systemThe tag can obtain all preset fields in the background "Global Function Settings", including website name, Logo, filing number, copyright content, homepage address, mobile end address, static file address of template, template directory name, shutdown prompt content, site language, etc. In addition, if you add custom parameters in the background "Global Function Settings", you can also access them throughname="你自定义的参数名"Get it.
Q2: My AnQi CMS has installed multiple sites, how can I display the logo of the child site in the main site template?A2: systemTag supportsiteIdParameter. You can obtain the global information of a sub-site by specifying its ID. For example, if your sub-site ID is 2, you can get its Logo in this way:{% system subSiteLogo with name="SiteLogo" siteId="2" %}Make sure you have got it right.siteId.
Q3: I have modified the logo or website name on the back-end, but the front-end page has not been updated. Why is that?A3: This is usually due to browser or server cache.Firstly, try to clear the browser cache (hard refresh the page), if it is still invalid, you can log in to the Anqi CMS backend, click the "Update Cache" button in the left menu to clear the system cache.If your website uses a CDN, you may also need to clear the CDN cache.