In website operation, we often need to display some global website information, such as website name, Logo, filing number, copyright statement, as well as custom contact information or social media links.This information, if directly hardcoded in the template, would require searching and updating each page individually when modifications are needed, which is time-consuming, labor-intensive, and prone to errors.systemTags, allowing these system configuration information to be dynamically obtained and displayed in templates, greatly enhancing the maintainability and operational efficiency of the website.
systemTag: convenient entry to website information
systemLabels are the core tools used by AnQi CMS to retrieve each configuration item from the "Global Function Settings" in the background.Through it, you can flexibly call website name, Logo, basic link and a series of important system-level data at any location of the website template.
Its basic usage is very intuitive:{% system 变量名称 with name="字段名称" %}.
Here,name="字段名称"Used to specify the specific system configuration item you want to obtain,变量名称It is optional. If you provide a variable name, the value of this configuration item will be stored in this variable, and you can use it in the subsequent code.{{变量名称}}AutosystemTags will directly output the configuration value to the current position.
In addition to getting the information of the current site,systemtags support ansiteIdParameters. If you are managing multiple sites and need to call system configurations from other sites,siteIdSpecify the target site. But in most cases, we usually only need to get the information of the current site, so this parameter can be ignored.
Get the common system configuration information
Next, let's take a look atsystemThe label can obtain specific configurations and how to call them in the template.
Website name (SiteName)
This is the basic identification of the website, usually displayed in the browser title bar, next to the Logo, or in the footer.
{# 直接输出网站名称 #}
<div>网站名称:{% system with name="SiteName" %}</div>
{# 将网站名称赋值给变量并输出 #}
<div>网站名称:{% system currentSiteName with name="SiteName" %}{{currentSiteName}}</div>
Website Logo (SiteLogo)
The brand logo of the website, usually a picture link.
{# 直接输出Logo图片,并使用网站名称作为alt属性,提升SEO #}
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
{# 将Logo链接赋值给变量,再构建图片标签 #}
{% system siteLogoPath with name="SiteLogo" %}
<img src="{{siteLogoPath}}" alt="{% system with name="SiteName" %}" />
Website filing number (SiteIcp)
In accordance with national regulations, the record information is usually displayed in the footer of the website.
{# 显示备案号,并链接到工信部备案查询平台 #}
<p><a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a></p>
Copyright content (SiteCopyright)
This is the copyright statement for the footer, which can include the year, company name, etc.
{# 直接输出版权信息,注意使用safe过滤器以防HTML内容被转义 #}
<div>{% system with name="SiteCopyright"|safe %}</div>
{# 赋值给变量并输出 #}
{% system copyrightInfo with name="SiteCopyright" %}
<div>{{copyrightInfo|safe}}</div>
Website Home Address (BaseUrl)
This is the root URL of the website, very useful when building absolute links.
{# 获取网站首页地址,用于构建返回首页的链接 #}
<a href="{% system with name="BaseUrl" %}" class="home-link">返回首页</a>
Address of the website for mobile devices (MobileUrl)
If your website has enabled a separate mobile domain (configured in the "Global Feature Settings" backend), you can get it here.
{# 在PC端判断并提供手机端链接,引导用户切换 #}
{% system mobileSiteUrl with name="MobileUrl" %}
{% if mobileSiteUrl %}
<a href="{{mobileSiteUrl}}" class="mobile-version-link">访问手机版</a>
{% endif %}
Template Static File Address (TemplateUrl)
Used to link to static resources under the template directory such as CSS, JS, images, etc., ensuring the path is correct.
{# 链接模板目录下的样式表 #}
<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
{# 链接模板目录下的JavaScript文件 #}
<script src="{% system with name="TemplateUrl" %}/js/main.js"></script>
Station closure prompt content (SiteCloseTips)
When the website is in maintenance or closed, the system will display the prompt information configured here.
{# 在网站维护页面显示闭站提示 #}
<div class="maintenance-message">
<p>{% system with name="SiteCloseTips" %}</p>
</div>
Site language (Language)
Indicates the language used by the current website, often used for<html>Tagslangproperties.
{# 在HTML根标签中设置语言属性 #}
<html lang="{% system with name='Language' %}">
Custom Parameters
The strength of Anqi CMS also lies in its high customizability.In the "Global Function Settings" on the backend, you can add any number of custom parameters to meet the personalized call needs of the template.For example, you may want to add a "WeChat Official Account QR code" or "Help Page Link" and other non-built-in configuration items.
Assuming you have created a namedHelpPageUrlEnglish custom parameter, value ishttps://www.yourdomain.com/help. You can call it like this in the template:
{# 调用自定义的帮助页面链接 #}
<a href="{% system with name="HelpPageUrl" %}">访问帮助中心</a>
{# 将自定义参数赋值给变量 #}
{% system helpLink with name="HelpPageUrl" %}
<p>更多信息请点击:<a href="{{helpLink}}">{{helpLink}}</a></p>
Practical suggestions and flexible application
Rationally utilizesystemtags, making your website template more flexible. You can place them in the public header file (such aspartial/header.html)中调用SiteName/SiteLogoandTemplateUrlIn the footer file (such aspartial/footer.html)中调用SiteIcpandSiteCopyright, and manage the custom contact information or social media links through the custom parameters.Thus, once a piece of information needs to be updated, it only needs to be modified once in the background, and all pages that call the information will be automatically synchronized updated, greatly reducing the cost and risk of manual intervention.
In addition,systemThe information obtained from the label is dynamic, which means that when you change the configuration in the background, the front-end page will immediately reflect these changes (unless there is a caching mechanism involved, but usually refreshing the page is enough to see them).This is crucial for the daily maintenance of the website and for quickly responding to market changes.
In this way, the Anqi CMS not only provides powerful content management capabilities, but also throughsystemA series of flexible template tools, which give website operators a high degree of control, making website management unprecedentedly easy and efficient.
Common Questions (FAQ)
1. I have modified the system settings in the background, but the front-end page did not update immediately, why is that?AnQi CMS usually improves the website access speed through caching mechanisms.If you have modified the system configuration in the background, but the new content is not displayed on the front-end page immediately, it may be because the cache has not been refreshed.Try clearing the browser cache, or go to the “Update Cache” feature in the Safety CMS backend and execute it, you should see the latest configuration usually.
2. Use in the templatesystemWhen calling custom parameters for tags,namehow should the properties be filled in?
nameThe value of the attribute should be exactly the same as the "parameter name" you entered when adding custom parameters in the "Global Function Settings" backend. Please note that Aiqi CMS is case-sensitive with parameter names and it will automatically convert the input letters to camelCase (for example, if you enterhelp page urlMay be processed by the systemHelpPageUrl),therefore please ensure that the templatenamematches the actual parameter name stored on the back-end
3.BaseUrlandTemplateUrlWhat is the difference? When should I use them?
BaseUrlIt is the root address of the website, for examplehttps://www.yourdomain.com/, it is mainly used to construct absolute links for internal pages, ensuring that users can be correctly directed to the target page regardless of where they navigate from.TemplateUrlThis is the current activity template directory URL, for examplehttps://www.yourdomain.com/template/default/It is mainly used to refer to static resources within templates, such as CSS, JavaScript files, or images, ensuring that these resources can be loaded correctly by the browser. Simply put,BaseUrlIt is the basis of website content navigation,TemplateUrlIt is the basis of template resource loading.