When building and managing a website, we often need to ensure that core brand information, such as the website name, Logo, and the registration number required by laws and regulations, can be consistent on all pages of the website and can be updated at any time.AnqiCMS provides a user-friendly and powerful template system, making it very simple and efficient to call and display these global configuration information on the front page.
The '万能钥匙' in AnqiCMS template system:systemTag
AnqiCMS template system uses a syntax similar to Django, it provides a namedsystemThe core label, specially used for calling and displaying various information configured in the background "Global Function Settings".You can imagine it as a convenient channel, directly connecting to your website configuration center.
UsesystemThe tag is very flexible. You can choose to directly output the required value, or you can assign it to a variable and then reference it elsewhere in the template. The basic call format is{% system 变量名称 with name="字段名称" %}. Among them,nameThe parameter is used to specify which system configuration to retrieve.
Let's look at several common and practical examples to see how to flexibly use it on the front page.system.
The website name is called and displayed
The website name usually appears in the browser title bar (<title>tag) and page content to identify the website. BysystemLabels, it becomes easy to get the website name.
You can directly insert it at the required position, like in HTML.<head>Partly, in order to optimize search engine results, the page title usually contains the content of the page itself followed by the site name as a suffix. Although AnqiCMS has specialtdkTags to handle the page Title, Keywords, and Description, but if you just want to display the website name directly in the page content,systemThe tag is preferred:
<title>我的页面标题 - {% system with name="SiteName" %}</title>
<h1>欢迎访问 {% system with name="SiteName" %}!</h1>
Displaying the website logo
The website logo is the visual core of the brand image, generally placed at the top of the website, in the navigation bar, and other prominent positions. The URL to obtain the logo image is equally simple and clear:
<a href="/">
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %} Logo" />
</a>
Here we not only called the Logo URL (SiteLogo) but also used the previously obtained website name (SiteName) as the image'saltThe attribute value is very helpful for improving the accessibility (Accessibility) and search engine optimization (SEO) of the website.
The display and call of the record number.
For domestic websites, the filing number is a legal requirement that must be displayed, usually placed at the footer of the website. ThroughsystemThe tag calls the filing number very directly:
<p>
<a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">
{% system with name="SiteIcp" %}
</a>
© {% now "2006" %} {% system with name="SiteName" %} 版权所有
</p>
This code not only displays the filing number but also automatically generates a link to the Ministry of Industry and Information Technology filing query website and addsrel="nofollow"andtarget="_blank"Attributes, all this is common **practice for footer links. At the same time, we also called the current year ({% now "2006" %}) and the website name to construct the complete copyright statement.
Copyright information call and display
In addition to the filing number, the copyright information of the website is often found in the footer. If your copyright information may contain HTML tags (such as bold, links, etc.), don't forget to use them when calling.|safeA filter to ensure that HTML content is parsed and displayed correctly, rather than being escaped as plain text.
<div>
{% system siteCopyright with name="SiteCopyright" %}
{{ siteCopyright|safe }}
</div>
Here, we first declareSiteCopyrightthe content to assign tositeCopyrightthe variable, then through{{ siteCopyright|safe }}Output, ensure that its HTML structure is not destroyed.
Call custom global parameters
The strength of AnqiCMS lies in its ability to allow more custom global configuration parameters. For example, if you want to display a specific "help page link" in some place on the website, and this link does not belong to any built-in system field, you can add a custom parameter in the "global feature settings" back-end, for example namedHelpUrlThen you can call it like this in the template:
<nav>
<a href="{% system with name="HelpUrl" %}">获取帮助</a>
</nav>
Modify it in the background as long as this way is used.HelpUrlThe value, all pages that call it will synchronize the update, greatly improving management efficiency.
Integrate information into the template.
These system configuration information is usually placed in the public template files of the website, such asbase.html(the overall framework of the website),header.html(the header part) orfooter.html(Footer section). By calling these core files appropriatelysystemLabel, you can ensure that all pages of the website display these key information uniformly, avoiding repeated modification and potential inconsistencies.
In summary, throughsystemLabel, AnqiCMS allows website operators to manage and display global configuration information of the website flexibly and efficiently.Whether you need to update the website name, change the logo, or adjust the filing number, you only need to perform one operation in the background, and the front-end page will be synchronized updated, greatly improving the efficiency and consistency of content management, keeping your website always up-to-date and professional.
Frequently Asked Questions (FAQ)
1. I have modified the website name or Logo in the background, but the front page did not update immediately, what is the matter?
This is usually caused by browser cache or AnqiCMS system cache.First, you can try clearing the browser cache and then force refresh the page.If the problem persists, please log in to the AnqiCMS backend, find and click the "Update Cache" feature in the left menu, manually clear the system cache, and the page content should display normally.
2. I want to<title>How to display the current page title and website name at the same time?
AnqiCMS provides special for the page Title, Keywords, and Description (TDK)tdkLabel. Use this label to control the SEO elements of the page more finely. For example, in the page<head>section, you can set it like this:
<title>{% tdk with name="Title" siteName=true %}</title>
here,tdkThe tag will automatically retrieve the title of the current page andsiteName=trueThe parameter automatically appends the site name as a suffix to the page title, thus generating a complete, SEO-friendly page title.
**3. If I want to display the phone number, email, and other information in the "Contact Information Settings" on the front end, do I also use `