During the construction and maintenance of websites, we often encounter the need to display basic information about the website at various positions on the page, such as the name of the website, Logo, copyright statement, filing number, and so on.If this information is scattered in various corners of the template, it will be very cumbersome and prone to errors once it needs to be modified.Then, what kind of solution does AnQiCMS provide in this regard?Does it support us getting and displaying these system-level configuration information directly in the template?
The answer is affirmative. AnQiCMS is an efficient content management system that fully considers the convenience and flexibility of template development. It provides a powerfulSystem settings label (system)Allow template developers to easily call various system information configured in the background in any template file.
systemTags: One-stop access to basic website information
systemThe tag is a core and practical tag in the AnQiCMS template engine, its design philosophy is to directly expose the information configured in the "Global Function Settings" of the website backend to the front-end template.This means that whether you need to display the website name, Logo, or other key information uniformly set in the background, you can easily obtain it through this tag.
systemThe basic usage of tags is very intuitive:
{% system 变量名称 with name="字段名称" %}
Here, "field name" corresponds to the English name of the parameters configured in the "Global Function Settings" of the AnQiCMS backend. For example, to get the website name, the field name isSiteName; To get the website logo, the field name isSiteLogo.变量名称Optional, if you want to assign the obtained value to a variable for subsequent processing, you can specify it; if you simply want to output it directly, you can use the label directly.
Let's go through several specific examples to see how to usesystemtags to obtain and display common system configuration information.
1. Obtain and display the website name
The website name is the face of the website, usually used on the page.<title>Tags, next to Logo or footer. In the template, you can call it like this:
<title>{% system with name="SiteName" %}</title>
或者:
<div>欢迎访问:{% system with name="SiteName" %}</div>
If you want to assign the website name to a variable:
{% system siteName with name="SiteName" %}
<h1>{{ siteName }}</h1>
2. Get and display the website logo
The website logo is an important element of brand recognition, usually displayed in the header area. Get the URL of the website logo image:
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
here,altThe property is also used directly.SiteNameThe label ensures the accessibility of images and SEO-friendliness.
3. Display the website filing number and copyright information.
This information is usually located at the footer of the website, which is particularly important for domestic websites.
<p>
<a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a>
© {% now "2006" %} {% system with name="SiteCopyright" %}. All Rights Reserved.
</p>
Here we also combined with{% now "2006" %}tags to dynamically obtain the current year, keeping the copyright information up to date.
4. Get the homepage address and template static file address of the website
This information is crucial when building links or referencing static resources in the template.
<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
<a href="{% system with name="BaseUrl" %}">网站首页</a>
ByTemplateUrlYou can ensure that static resources load correctly regardless of the path where the website is deployed.
5. Flexible retrieval of custom parameters
The AnQiCMS backend "Global Function Settings" not only provides a series of default system configuration items but also allows you to add custom parameters according to your actual needs.This means that whether it is a customer service phone number, social media link, statistics code snippet, or any information you wish to manage centrally and call in a template, it can be achieved through custom parameters.
For example, if you add a namedCustomPhoneThe custom parameter, and set it to “400-123-4567”, then you can call it in the template like this:
<div>客服热线:{% system with name="CustomPhone" %}</div>
This custom mechanism greatly enhances the flexibility and maintainability of the template.
systemThe value brought by tags
BysystemLabel, AnQiCMS achieves a high degree of decoupling between website basic information and templates. Its advantages are obvious:
- Centralized management and unified update:All system-level configurations are centralized in the background, one-time modification takes effect throughout the site, greatly reducing maintenance costs.
- Improve development efficiency:Template developers do not need to hard-code website information, they just need to call the tag, which simplifies the development process.
- Ensure consistency of information:Avoided issues of inconsistent information due to manual modification, omissions, or typographical errors.
- Enhanced flexibility:By customizing parameters, it can easily expand configurable information to meet various complex business needs.
In summary, AnQiCMS'ssystemThe label is an excellent embodiment of its template development friendliness.It makes the acquisition and display of basic website information simpler and more efficient than ever before, providing users with a smooth and practical website operation experience.
Frequently Asked Questions (FAQ)
Q1: Has the website backend changed the website name or logo, will the front-end page update immediately?A1: In most cases, the AnQiCMS template reads the latest configuration information in real time.If you encounter situations where updates are not timely, it may be due to browser caching or the system cache of AnQiCMS.You can try clearing the browser cache (Ctrl+F5) or manually clearing the system cache in the 'Update Cache' feature of AnQiCMS backend, and the page will display the latest content.
Q2: Besides the website name and logo, can yousystemWhat information does the tag get commonly?A2:systemThe tag is very comprehensive, in addition to the website name and Logo, you can also easily get the website filing number (SiteIcp), copyright information (SiteCopyright)、Website Home Address(BaseUrl)、Mobile End Address(MobileUrl)、Template Static Files Address(TemplateUrl), as well as any parameters you customize in the background "Global Function Settings". This allows for the centralized management and calling of various general information on the website.
Q3: Can I use it in any template file (such as header, sidebar, article detail page)?systemAm I supposed to use the label?A3: Yes,systemThe label is a globally available system-level label. You can use it anywhere in the AnQiCMS template system, whether it is in a public header file (such aspartial/header.html), footer file, or specific article detail page, category list page, can easily call the system configuration information.This greatly facilitates the modular design and unified management of the template.