How to use the `system` tag to obtain website name, LOGO, filing number and other system information?

As an experienced Anqi CMS website operator, I am well aware of the importance of dynamically obtaining basic website information in daily template development and content presentation. In order to ensure the uniformity, maintainability, and efficient management of the website, Anqi CMS provides an extremely convenientsystemThe tag allows template developers to directly call various system-level data from the background global settings, thus avoiding the inconvenience of hard coding.

The website name, logo, filing number, and other information are key elements构成 brand image and legal compliance. ThroughsystemLabel, this information can be flexibly presented at various corners of the website, and synchronized in real time with the update of the background, greatly enhancing operational efficiency. Next, we will delve into how to make use ofsystemTags to retrieve and display this valuable system information.


UnderstandingsystemThe core function of the tag

systemThe tag is a powerful built-in tag in Anqi CMS template engine, which aims to help us dynamically obtain the global configuration information of the website.These configuration information is usually managed in the "Global Function Settings" of the Anqi CMS backend.systemWhen using the tag, we mainly go throughnameSpecify the specific information field required to obtain, such as the website name, logo address, etc. In addition, for the AnQi CMS running in a multi-site environment,systemTags also supportsiteIdParameters to accurately obtain system configuration from a specific site, which is particularly important when managing multiple sub-sites or independent brand sites, although it is usually not necessary to explicitly specify in most single-site applications.

Get the website name (SiteName)

The website name is the facade of the website, usually displayed in the browser title bar, website header, or footer. Bysystemtag to obtainSiteNameField, we can ensure that the names displayed throughout the website are always consistent with the backend settings.

For example, in the template, we can call the website name like this:

<div>网站名称:{% system with name="SiteName" %}</div>

Or, if you need to store the value you obtained in a variable for further operations:

<div>网站名称:{% system siteName with name="SiteName" %}{{siteName}}</div>

Display the website logo (SiteLogo)

The website logo is the core element of brand visual recognition. It is used tosystemtag to obtainSiteLogofield, which can dynamically load the website logo image URL and embed it into<img>In the label. This ensures that after the LOGO image is updated in the background, the front-end page does not need to modify the code and can automatically update.

Typical usage is shown as follows:

<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />

Here we not only obtain the LOGO address, but also recommend obtaining it simultaneouslySiteNameAs an imagealtAttribute values, which not only help with SEO optimization, but also improve the accessibility of the website.

Display the website filing number (SiteIcp)

For websites operating in mainland China, the filing number is a legally required necessary information. The AnQi CMS backend allows you to set the website filing number, and you can access it throughsystemTags are displayed in the footer of the website and other locations. Usually, the record number is linked to the Ministry of Industry and Information Technology's government service platform.

The following is an example of how to implement this function:

<p><a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a> &copy;2021 kandaoni.com. All Rights Reserved</p>

This code not only displays the filing number, but also automatically adds a link to the official filing inquiry website and setsrel="nofollow"andtarget="_blank"Properties, these are good SEO practices and considerations for user experience.

Display copyright information (SiteCopyright)

The website's copyright information is usually included in the footer area, used to declare the copyright of the website content.systemTags can easily retrieve the copyright content set in the background and display it in the template. If the copyright information contains HTML tags (such as&copy;symbols, links, etc.), it usually needs to be配合safeA filter to ensure that HTML content is rendered correctly rather than being escaped.

The following is an example of code to retrieve and display copyright information.

<div>{% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}</div>

By|safeFilter, we can ensure that the HTML format copyright statement input from the back-end is displayed as it is.

Get the website address (BaseUrl,MobileUrl)

BaseUrlThe field provides the root URL of the website, which is very useful for building internal links, redirects, or dynamically referencing resources in JavaScript.MobileUrlIt is specifically used to obtain the mobile end address of a website, which is particularly important when using the "computer + mobile independent site" mode.

For example, to obtain the home page address of a website:

<div>首页地址:{% system with name="BaseUrl" %}</div>

Get mobile end address:

<div>移动端地址:{% system mobileUrl with name="MobileUrl" %}{{mobileUrl|safe}}</div>

Use custom parameters (后台自定义设置的参数名)

Of Security CMSsystemLabels are not limited to built-in fields, they also support retrieving custom parameters set in the background "Global Function Settings". This means that you can add any additional website-level configuration items in the background according to your business needs, and throughsystemTags are called in the template, thus greatly enhancing the flexibility of the website.

Suppose you have customized a namedCustomerServiceHotlineThe parameter is used to store the customer service hotline, and you can call it like this in the template:

<div>客服热线:{% system with name="CustomerServiceHotline" %}</div>

Conclusion

systemsystemThe use of tags will undoubtedly make your Aqin CMS website management work more convenient.


Frequently Asked Questions

1. If a certain system setting in the background is not filled in,systemWhat will the label output?

If a certain system setting in the background, such as the website filing number,SiteIcpThis field has not been filled in, then when you use it in the template{% system with name="SiteIcp" %}When labeling, it will not output anything, or output an empty string. To avoid blank spaces or unnecessary placeholders on the page, you can use conditional judgments in the template (such as{% if %}Label) to check if the obtained value is empty, and display it only if the value exists.

2. In multi-site mode,systemHow to differentiate the configuration of labels for different sites?

In Anqi CMS's multi-site management feature, each site has an independent global setting.systemLabels are optional.siteIdParameters to specify which site's system configuration to retrieve. If you do not specifysiteIdparameter,systemThe tag will default to retrieving the system configuration of the current visited site. For example,{% system siteName with name="SiteName" siteId="2" %}Will retrieve the website name of the site with ID 2. This is very useful for scenarios that require cross-site referencing of system information or developing universal templates.

3.systemCan the tag retrieve all system settings at once without specifying each onename?

systemThe design intention of the tag is to accurately obtain a single system configuration item to provide the greatest flexibility and the least performance overhead.Therefore, it does not support returning all system settings as an object at once.systemLabel to sequentially obtain the website name, LOGO, filing number, and other information. This design ensures that the template only loads and processes the required data, maintaining lightness and efficiency.