In website construction and daily operation, we often encounter situations where we need to display some global information, such as the name of the website, Logo, filing number, contact information, etc.This information runs through the entire website and needs to be consistent across multiple pages.AnQiCMS provides an extremely convenient way to handle such global information, that is, through its built-insystemTemplate label.
Get to knowsystemLabel: Key to get global information of the website
systemTags are like keys that can help you easily retrieve and display various global website information configured in the background "Global Feature Settings" template.You do not need to manually copy the code or worry about inconsistent information, just call it, AnQiCMS will automatically render the latest global settings for you.
Its basic usage method is very intuitive:
{% system 变量名称 with name="字段名称" %}
There are two core parts that need to be understood here:
name="字段名称"This is the most important part, it specifies the specific global information you want to obtain. For example, if you want to get the website name, then字段名称that isSiteName; if you want to get the website logo, that isSiteLogoThese field names are usually corresponding to the items in the background setting page.变量名称This is an optional parameter. If you want to store the global information obtained into a variable for reuse in other parts of the template or for some complex logic processing, you can give it a variable name, for examplesiteName)。If you do not need to store it, you can omit the variable name, AnQiCMS will directly output the corresponding value at the current position.
In addition, for users managing multiple sites,systemLabels also support asiteIdParameters allow you to specify the information to be retrieved from a specific site. However, in most single-site cases, we usually do not need to set this parameter, as the tag automatically retrieves information about the current site.
Common global information and its retrieval method
Now, let's look at how to use it through some specific examplessystemTags to retrieve and display common website global information:
Website name (
SiteName)This is the brand name of the website, usually displayed in the browser title bar, web page header, and other locations.<title>{% system with name="SiteName" %}</title> <h1>欢迎来到 {% system with name="SiteName" %}</h1>Website Logo (
SiteLogo)The visual identity of the website, generally appearing in the header.<a href="/"> <img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" /> </a>Website filing number (
SiteIcp)If your website is registered, this information is usually required to be displayed at the bottom of the website.<p><a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a></p>Copyright content (
SiteCopyright) with the current yearCommon footer copyright statements usually include the current year. AnQiCMS provides a{% now "2006" %}tag to conveniently get the current year.<div> {% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}} © {% now "2006" %}. All Rights Reserved. </div>Here, we first declare
SiteCopyrightthe content to assign tositeCopyrightthe variable, and then use|safeThe filter ensures that content with HTML code can also be parsed and displayed correctly.The home page address (
BaseUrl)This tag comes in handy when you need to retrieve the root directory URL of a website.<link rel="home" href="{% system with name="BaseUrl" %}" />Static file address of the template (
TemplateUrl)The CSS, JS, and images of the template are usually stored in a specific directory. UseTemplateUrlIt can help you build the correct path for static files.<link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet"> <script src="{% system with name="TemplateUrl" %}/js/main.js"></script>Site language (
Language)If you have set the default language of the website in the background, you can get the language code through this tag, usually used in HTML tags.langProperty.<html lang="{% system with name='Language' %}">Custom parameters (
后台自定义设置的参数名)AnQiCMS allows you to add custom parameters in the background "Global Function Settings".These parameters can be your website's unique contact information, social media links, or any information you need to globally call.For example, if you add a namedHelpUrlYou can call it like this:<div>我们的帮助页面:<a href="{% system with name="HelpUrl" %}" target="_blank">点击这里</a></div>
Integrate global information into the website
BysystemTags, we can easily call these global information in various parts of the website (such as headers, footers, sidebars, etc.), thereby ensuring the consistency and maintainability of the entire website. For example, a typical website footer may contain copyright information, filing number, and contact information, which can be accessed throughsystemTags andcontactLabel (for contact information) combination implementation:
<footer>
<div class="container">
<p>
{% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}
© {% now "2006" %}. All Rights Reserved.
</p>
<p>
备案号:<a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a>
</p>
<address>
联系我们:{% contact with name="Cellphone" %} | 邮箱:{% contact with name="Email" %}
</address>
</div>
</footer>
Summary
systemThe template tag is a very practical feature in AnQiCMS, which greatly simplifies the management and display of global information on the website.By flexibly using this tag, you can easily build a website with clear structure, consistent information, and easy maintenance, making your content operations more efficient.
Frequently Asked Questions (FAQ)
Q1: I added a custom parameter in the "Global Function Settings" backend, how can I call it in the frontend template?A1: Very simple. Suppose you add a custom parameter named "Social Media Link" in the background, and fill in the "Parameter Name" asSocialMediaLinkand set the value. In the front-end template, you can access{% system with name="SocialMediaLink" %}to retrieve and display this value.
Q2: Has my website enabled the multi-site management feature? Do I want to display the global information of another site in the template of one of the sites, can it be achieved?A2: OK.systemTag supportsiteIdParameter. You need to know the target site'ssiteId(It is usually visible on the multi-site management page in the backend), and then call it like this:{% system with name="SiteName" siteId="2" %}This will display the website name of the site with ID 2.
Q3: Why did the front page not update immediately after I modified the global settings in the background?A3: This could be due to the system cache of AnQiCMS.You can try to clear the system cache. In the AnQiCMS backend, there is usually an option like "Update Cache" or similar, click it to refresh the cache and make the global settings take effect immediately.If the problem still exists, please check if the field names in the template are spelled correctly and if any are missing{% system ... %}.