As an experienced website operator proficient in AnQi CMS content management, publishing, and optimization, I fully understand the importance of obtaining website global configuration information for website construction and daily maintenance.This information constitutes the basic framework of the website, including brand identity, contact information, SEO metadata, etc., ensuring the unity, professionalism, and maintainability of the website.In AnQi CMS, obtaining these global system configuration information is intuitive and flexible, mainly through built-in template tags.
Understanding the importance of global system configuration
The global system configuration information is the foundation of website operation. It is not just simple as the website name and Logo, it also includes the filing number, copyright information, basic URL, mobile end adaptation address, and even custom parameters defined to meet specific business needs.Centralized management of these configurations and convenient calling greatly enhances the efficiency of website operation, ensures consistency of brand image, and provides a unified entry for multi-site management.In AnQi CMS, this information is usually configured in the background "Global Settings" and called through specific tags in the template.
BysystemTagging to obtain core system information
Security CMS provides a powerfulsystemTemplate tag, used to obtain and display various global system configuration information in the website front-end template.This label's design concept is simple and efficient, allowing template developers to easily integrate these preset or custom configurations.
The basic usage of this tag is:{% system 变量名称 with name="字段名称" %}. Among them,nameThe parameter is the specific configuration item to be obtained, and变量名称It allows you to assign the obtained value to a temporary variable for more complex processing or display in the subsequent part of the template.If you do not need to assign the value to a variable, you can directly output the result.
Website name (SiteName) and the website logo (SiteLogo)
The website name is the identity of the website, which is usually displayed in the web page title, header, or footer and other key positions.The website logo is the visual symbol of the brand. In Anqi CMS, you can obtain them in the following way:
To get the website name:
{# 直接输出网站名称 #}
<div>网站名称:{% system with name="SiteName" %}</div>
{# 将网站名称赋给一个变量并输出 #}
<div>网站名称:{% system siteName with name="SiteName" %}{{siteName}}</div>
To get the URL of the website logo:
{# 直接输出网站Logo并结合网站名称作为alt属性 #}
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
{# 将网站Logo赋给一个变量,并结合网站名称作为alt属性输出 #}
<img src="{% system siteLogo with name="SiteLogo" %}{{siteLogo}}" alt="{% system siteName with name="SiteName" %}{{siteName}}" />
Website filing number (SiteIcp) and copyright content (SiteCopyright)
The filing number and copyright information are usually located at the footer of the website, which is an important statement of the website's compliance and ownership.
Retrieve website filing number:
{# 输出网站备案号,并链接到工信部备案查询网站 #}
<p><a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a></p>
Retrieve copyright content:
{# 输出版权内容 #}
<div>{% system with name="SiteCopyright" %}</div>
{# 将版权内容赋给一个变量并输出,注意此处使用 |safe 过滤器以防HTML内容被转义 #}
<div>{% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}</div>
Website base URL (BaseUrl) and the mobile address (MobileUrl)
The base URL of a website is the root address of the website, which is very useful when building internal links or referencing resources. If your website has a separate mobile end address, it can also be accessed throughMobileUrlRetrieve.
Get the website home page address:
{# 输出网站首页地址 #}
<div>首页地址:{% system with name="BaseUrl" %}</div>
Get the website mobile page address:
{# 输出移动端地址 #}
<div>移动端地址:{% system with name="MobileUrl" %}</div>
Static file address of the template (TemplateUrl) and template directory name (TemplateName)
It is crucial to obtain the path information of the template itself when developing and integrating custom templates, in order to correctly reference static resources such as CSS, JavaScript, and images.
Get the template static file address:
{# 引用CSS文件时,结合模板静态文件地址 #}
<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
Get the template directory name:
{# 获取当前正在使用的模板的目录名称 #}
<div>当前模板目录:{% system with name="TemplateName" %}</div>
Closed site prompt content (SiteCloseTips) and site language (Language)
When the website is in maintenance or closed state,SiteCloseTipscan be used to display prompts to users.LanguageThis indicates the default language of the website.
Get the shutdown prompt content:
{# 输出闭站提示信息 #}
<div>{% system with name="SiteCloseTips" %}</div>
Get the site language:
{# 将站点语言设置为HTML文档的lang属性 #}
<html lang="{% system with name='Language' %}">
Custom parameter
The strength of AnQi CMS also lies in its high customizability. If you add custom system parameters in the "Global Settings" backend (such as a customer service phone number or a specific social media link), you can also access them throughsystemTag to retrieve these values.
Assuming you have added a custom parameter named "CustomerServicePhone" in the background:
{# 输出自定义的客服电话号码 #}
<div>客服热线:{% system with name="CustomerServicePhone" %}</div>
{# 将自定义参数赋给一个变量并输出 #}
<div>联系我们:{% system phone with name="CustomerServicePhone" %}{{phone}}</div>
Under a multi-site environmentsiteIdParameter
The AnQi CMS supports multi-site management, which means you can manage multiple independent websites under a single AnQi CMS instance. In a multi-site environment, if you need to call a template in a specific siteother sitesThe system configuration information can be usedsiteIdSpecify the target site with parameters
For example, display the website name of the child site in the footer of a main site:
{# 获取siteId为2的站点的网站名称 #}
<div>子站点名称:{% system with name="SiteName" siteId="2" %}</div>
In most cases, if you just want to get the configuration of the current site,siteIdThe parameter can be omitted, the system will automatically identify the current site.
By using these methods, you can comprehensively and flexibly obtain and utilize the global system configuration information of AnQi CMS, whether it is for displaying website basic information, optimizing SEO, or implementing complex multi-site linkage.
Frequently Asked Questions (FAQ)
1. I added a new custom parameter in the background "Global Settings", but why can't I pass it through the template?{% system with name="我的参数名" %}Obtained?
Please make sure you are innameThe field name used in the parameter must match the "parameter name" set in the background and must be in camel case (i.e., each word starts with an uppercase letter without spaces). For example, if the parameter name set in the background is "Customer Service Hotline", then in the template you should use{% system with name="CustomerServiceHotline" %}Try to get, or use the English 'field name' you set in the background (if filled in).If it still cannot be obtained, please check if the parameters have been saved successfully, or if there is any outdated cache (you can try to clear the system cache).
2. Why didn't the front page update immediately after I modified the website name or Logo in the background?
AnQi CMS to improve website performance will use cache mechanism.After you modify the global configuration on the back-end, you may need to manually clear the system cache to make the changes take effect immediately on the front-end.You can find the "Update Cache" feature in the AnQi CMS backend, click to execute it.In addition, browser caching may also cause display delays. It is recommended to clear the system cache and then try to clear the browser cache or access in incognito mode.
3. How to judge whether the current website is in a shutdown state and display specific information when it is shutdown?
You can usesystemLabel to get the website status, and combine withifLogical judgment tags to control the display of content. In the "Global Settings" of AnQi CMS, there is an option called "Website Status".When the website is set to a closed station status, you can get its value and make a judgment:
{# 假设有一个系统参数名为SiteStatus,表示网站是否关闭,或者直接用 SiteCloseTips 来判断 #}
{% system closeTips with name="SiteCloseTips" %}
{% if closeTips %} {# 如果闭站提示存在,说明网站已关闭 #}
<div class="website-closed-message">
<h2>网站正在维护中</h2>
<p>{{ closeTips }}</p>
</div>
{% else %}
{# 正常网站内容 #}
<!-- ... -->
{% endif %}
In this way, you can flexibly control the display content of the website under different states.