As an experienced website operator proficient in the CMS content management, publishing, and optimization, I fully understand the importance of obtaining the global configuration information of the website 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 the AnQi CMS, obtaining these global system configuration information is intuitive and flexible, mainly achieved 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 the website name and Logo, it also includes the filing number, copyright information, basic URL, mobile adaptation address, and even custom parameters defined to meet specific business needs.These configurations' centralized management and convenient invocation greatly enhance the efficiency of website operation, ensure the consistency of brand image, and provide a unified entry for multi-site management.In the AnQi CMS, this information is usually configured in the "Global Settings" on the backend and called through specific tags in the template.
PasssystemTagging to obtain core system information
Auto 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 philosophy is simple and efficient, allowing template developers to easily integrate these preset or customized configurations.
The basic usage of this tag is:{% system 变量名称 with name="字段名称" %}.nameThe parameter specifies the specific configuration item to be obtained, and变量名称This allows you to assign the retrieved 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 website logo (SiteLogo)
The website name is the identity identifier of the website, which usually appears in the web page title, header, or footer, etc.The website logo is the visual symbol of the brand.
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 record number and copyright information are usually located in the footer of the website page, which is an important statement of the website's compliance and ownership.
Get website record number:
{# 输出网站备案号,并链接到工信部备案查询网站 #}
<p><a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a></p>
Get copyright content:
{# 输出版权内容 #}
<div>{% system with name="SiteCopyright" %}</div>
{# 将版权内容赋给一个变量并输出,注意此处使用 |safe 过滤器以防HTML内容被转义 #}
<div>{% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}</div>
Website base URL (BaseUrl) and mobile end address (MobileUrl)
The base URL of the website is the root address of the website, which is very useful when building internal links or referencing resources. If your website has configured a separate mobile address, it can also be accessed throughMobileUrlretrieved.
Get the home page address of the website:
{# 输出网站首页地址 #}
<div>首页地址:{% system with name="BaseUrl" %}</div>
Get the mobile page address of the website:
{# 输出移动端地址 #}
<div>移动端地址:{% system with name="MobileUrl" %}</div>
Template Static File Address (TemplateUrl) and the template directory name (TemplateName)
When developing and integrating custom templates, it is crucial to obtain the path information of the template itself to correctly reference CSS, JavaScript, and images, etc. static resources.
Get the static file address of the template:
{# 引用CSS文件时,结合模板静态文件地址 #}
<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
Get the template directory name:
{# 获取当前正在使用的模板的目录名称 #}
<div>当前模板目录:{% system with name="TemplateName" %}</div>
Station closure prompt content (SiteCloseTips) and site language (Language)
When the website is in maintenance or closed status,SiteCloseTipsCan be used to display prompt information to users.LanguageIndicates the default language of the website.
Get the content of the shutdown prompt:
{# 输出闭站提示信息 #}
<div>{% system with name="SiteCloseTips" %}</div>
Get the site language:
{# 将站点语言设置为HTML文档的lang属性 #}
<html lang="{% system with name='Language' %}">
Custom Parameters
The strength of AnQi CMS lies in its high customizability. If you add custom system parameters (such as a customer service phone number or a specific social media link) in the "Global Settings" backend, you can also go throughsystemLabel 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>
Environment with multiple sitessiteIdParameters
AutoCMS supports multi-site management, which means you can manage multiple independent websites under a single AutoCMS instance. In a multi-site environment, if you need to call a template in a specific siteother sitesThe system configuration information, can be usedsiteIdthe parameter to specify the target site.
For example, display the website name of its child site in the footer of a primary site:
{# 获取siteId为2的站点的网站名称 #}
<div>子站点名称:{% system with name="SiteName" siteId="2" %}</div>
Generally, 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.
Through 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.
Common Questions and Answers (FAQ)
1. I added a new custom parameter in the background "Global Settings", but why can't I access it in the template?{% system with name="我的参数名" %}Get?
Make sure you are innameThe field name used in the parameter matches the "Parameter Name{% system with name="CustomerServiceHotline" %}Try to get it, or use the English "Field Name" you set in the background (if filled in).If it still cannot be retrieved, please check if the parameters have been saved successfully, or if there is any cache that has not been updated (you can try to clear the system cache).
2. Why doesn't the front page update immediately after I modify the website name or Logo on the backend?
The AnQi CMS will use a caching mechanism to improve website performance.When you modify the global configuration on the backend, 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.In addition, browser caching may also cause display delay. It is recommended to try clearing the browser cache or accessing in incognito mode after clearing the system cache.
3. How to determine if the current website is in a shutdown state, and display specific information when it is?
You can usesystemTag to obtain website status, and combineifLogic judgment label to control the display of content.In the "Global Settings
{# 假设有一个系统参数名为SiteStatus,表示网站是否关闭,或者直接用 SiteCloseTips 来判断 #}
{% system closeTips with name="SiteCloseTips" %}
{% if closeTips %} {# 如果闭站提示存在,说明网站已关闭 #}
<div class="website-closed-message">
<h2>网站正在维护中</h2>
<p>{{ closeTips }}</p>
</div>
{% else %}
{# 正常网站内容 #}
<!-- ... -->
{% endif %}
Through this method, you can flexibly control the display content of the website in different states.