In AnQiCMS, efficiently managing the core information of the website is the key to building a flexible and easy-to-maintain website.The website name, logo, and copyright statement are important components of brand image and legal statements, and they usually need to be consistent across multiple pages of the website.systemLabels provide a concise and effective way to dynamically retrieve and display this information, greatly enhancing the development efficiency and maintenance convenience of the website.
UnderstandingsystemThe core function of template tags
In the "Global Function Settings" of AnqiCMS backend, you can configure a series of basic information about the website, including website name, Logo image, filing number, and copyright information.systemThe template tags are the "representatives" of these global settings in the front-end template. It allows you to specifynameThe properties can be accessed to these predefined field values. This means that once you modify this information in the background, all pages with tags will automatically update without manual modification of the template code.systemThe pages with tags will automatically update without manual modification of the template code.
systemThe basic format of the label is{% system 变量名称 with name="字段名称" %}.变量名称Is optional, if you specify it, the value obtained will be stored in this variable, convenient for you to use in the subsequent template logic; if you omit it,变量名称If so, the tag will directly output the value of the corresponding field.nameThe attribute is the identifier for the specific setting item you want to obtain, which corresponds to each field in the background settings.
Dynamic Display of Website Name (SiteName)
The website name is the most direct way to identify a website, which usually appears on the<title>Tags, as well as prominent positions such as headers and footers. In the "Global Feature SettingsSiteNamefield.
For example, if you want to display the website name in the title of the webpage, you can use it like this:
<title>{% system with name="SiteName" %}</title>
If you want to use the website name as a title for a part of the page and assign it to a variable for use in multiple places, you can do it like this:
{% system mySiteName with name="SiteName" %}
<header>
<h1>欢迎来到 {{ mySiteName }}</h1>
</header>
So, no matter how you modify the website name in the background, the front-end page will update in real time.
Dynamic display of the website logo (SiteLogo)
The website logo is the visual symbol of the brand, its display is crucial for brand recognition.AnqiCMS allows you to upload the website Logo image in the "Global Function Settings" on the backend.systemTagged throughSiteLogoField, can get the URL address of the Logo image.
When displaying the Logo image in HTML, it is usually combined with<img>Tag. To improve SEO and accessibility, it is recommended to use it simultaneously.altattributes to describe image content, here it is.altThe attribute value can also dynamically obtain the site name.
The following is an example of displaying a website logo:
<div class="site-logo">
<a href="/">
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}">
</a>
</div>
If you are accustomed to storing the Logo address in a variable before using it, you can do it like this:
{% system siteLogoPath with name="SiteLogo" %}
<div class="brand-identity">
<a href="/">
<img src="{{ siteLogoPath }}" alt="网站Logo图片">
</a>
</div>
Dynamically display copyright information (SiteCopyright)
Copyright information is usually located at the footer of a website, used to declare the ownership of the content. You can find the 'Copyright Information' setting option in the 'Global Function Settings' of AnqiCMS backend, which corresponds to the template.SiteCopyrightfield.
Due to copyright information may contain HTML tags (such as©symbols, links, etc.), it is recommended to use|safeFilter to ensure that these HTML contents are correctly parsed by the browser and not displayed as plain text.
Here is an example of a footer displaying copyright information:
<footer>
<p class="copyright-info">
{% system with name="SiteCopyright" %}|safe}}
</p>
</footer>
or, if you need to perform more complex processing on the copyright information, you can first assign it to a variable:
{% system copyrightContent with name="SiteCopyright" %}
<div class="footer-legal">
{{ copyrightContent|safe }}
<span class="current-year">© {% now "2006" %}</span> <!-- 结合当前年份标签 -->
</div>
Pass|safeFilter, you can ensure that any HTML content entered in the background is rendered correctly on the front-end. You can also combinenowLabel to dynamically display the current year, making the copyright information more perfect.
Summary
AnqiCMSsystemThe template tag is the core tool for dynamically displaying global information on the website front-end.It decouples the key configurations such as website name, Logo, and copyright information from template content, achieving a convenient management mode of one-time configuration and full-site update.This not only significantly improves the development efficiency and operational flexibility of the website, but also lays a foundation to ensure the consistency of website information, enhance user experience, and optimize search engine rankings.systemLabel, you will be able to build and manage a high-quality AnqiCMS website more easily.
Common Questions (FAQ)
Why does my website Logo image not display on the page although it was uploaded?
- First, please make sure that the Logo image has been successfully uploaded and saved in the "Global Function Settings" of the AnqiCMS background.
- Next, check the call in your template.
{% system with name="SiteLogo" %}The code is correct, especiallysrcproperties. - Finally, it may be due to browser cache. Try clearing the browser cache or force refresh the page (Ctrl+F5 or Cmd+Shift+R) to see the effect.If it still cannot be displayed, please check if the image path is correct or if there is a permission issue.
I entered the copyright information in the background
© 2023 All Rights ReservedHowever, the front-end page displayed it directly&copy; 2023 All Rights ReservedWhat's the matter?- This is because AnqiCMS (and many template engines) defaults to escaping HTML content to prevent potential security issues (such as XSS attacks).When you use HTML entities or tags in the copyright information, you need to tell the template engine that these contents are safe and do not need to be escaped.
- The solution is to call
SiteCopyrightField|safeFilter, for example:{% system with name="SiteCopyright" %}|safe}}.
If my website is multilingual or multi-site
systemWill the tags still work normally? Do I need to configure them separately for each site?systemLabels are typically used to obtain information for the current site or current language environment. If you have enabled the multi-site feature of AnqiCMS and each site has its own backend settings, then in the corresponding site template,systemLabels will automatically retrieve the configuration information of the current site.systemLabels are supportedsiteIdParameters (e.g.,){% system with name="SiteName" siteId="2" %}This is used to call data across sites in special cases, but it is usually advanced usage and does not need to be manually specified in most cases.In multi-site or multi-language environments, AnqiCMS will intelligently handle it for you.