In AnQiCMS, efficiently managing the core information of a 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.AnqiCMS powerful template tag system, especiallysystemTags 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 role of template tags.
In the AnqiCMS backend "Global Function Settings", you can configure a series of basic information about the website, including the website name, Logo image, filing number, and copyright information.systemThe template tag is the 'representative' of these global settings in the front-end template. It allows you to specifynameAccess these predefined field values. This means that once you modify this information in the background, all callssystemof the label pages will be automatically updated without manually modifying the template code.
systemThe basic format of tags is{% system 变量名称 with name="字段名称" %}. Among them,变量名称It is optional. If you specify it, the value obtained will be stored in this variable for use in subsequent template logic; if you omit it变量名称If the label is directly output, it will display the value of the corresponding field.nameThe attribute is the identifier of the specific setting item you want to obtain, corresponding to each field in the background settings.
Dynamically display the website name (SiteName)
The website name is the most direct way to identify the website identity and usually appears on the web page.<title>In labels, as well as in prominent positions such as the header and footer. In the AnqiCMS background 'Global Function Settings', the configured 'Website Name' corresponds to the template tag inSiteNamefield.
For example, if you want to display the website name in the page title, 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>
This way, no matter how you modify the website name in the background, the front-end page will update in real time.
Dynamically display 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 website Logo image in the background "Global Function Settings".In the template,systemTag throughSiteLogoField, can get the URL address of the Logo image.
When displaying the Logo image in HTML, it is usually combined with<img>Label. It is recommended to use it simultaneously for SEO and accessibilityaltAttribute to describe the image content, herealtThe attribute value can also dynamically obtain the website name.
This 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 used 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>
Dynamic Display of 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 in the 'Global Function Settings' of the AnqiCMS backend, which corresponds to the template.SiteCopyrightfield.
Due to copyright information that may contain HTML tags such as©symbols, links, etc.), it is recommended to use|safeA filter to ensure that this HTML content is parsed correctly 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 handle copyright information more complexly, you can assign it to a variable first:
{% system copyrightContent with name="SiteCopyright" %}
<div class="footer-legal">
{{ copyrightContent|safe }}
<span class="current-year">© {% now "2006" %}</span> <!-- 结合当前年份标签 -->
</div>
By|safeThe filter, you can ensure that any HTML content entered in the background can be correctly rendered on the front end. At the same time, you can also combinenowTags to dynamically display the current year, making the copyright information more perfect.
Summary
AnqiCMS'ssystemTemplate tags are the core tools for dynamically displaying global information on the website front-end.It decouples the website name, Logo, copyright information, and other key configurations from the template content, realizing a convenient management mode of one-time configuration and full-site update.This significantly improves the development efficiency and operational flexibility of the website, and also lays a solid foundation for ensuring the consistency of website information, enhancing user experience, and optimizing search engine rankings.Proficient in usingsystemTags, you will be able to build and manage a high-quality AnqiCMS website more easily.
Frequently Asked Questions (FAQ)
Why did my website logo image upload but not display on the page?
- Firstly, make sure that the Logo image has been successfully uploaded and saved in the 'Global Function Settings' of the AnqiCMS backend.
- Secondly, check the call in your template.
{% system with name="SiteLogo" %}Does the code work correctly, especiallysrcProperty. - Finally, it may be due to browser cache. Try clearing the browser cache or refreshing the page forcibly (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 are permission issues.
I entered the copyright information in the background
© 2023 All Rights ReservedBut 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 inform the template engine that this content is safe and does not need to be escaped.
- The solution is to call
SiteCopyrightUse when a field|safefor example:{% system with name="SiteCopyright" %}|safe}}.
If my website is multilingual or multi-site
systemWill the tag still work? Do I need to configure it separately for each site?systemTags are usually aimed at obtaining information for the current site or language environment. If you have enabled the multi-site feature of AnqiCMS and each site has an independent backend setting, then in the corresponding site template,systemThe tag automatically retrieves the configuration information of the current site.systemTags also supportsiteIdParameters (for example{% system with name="SiteName" siteId="2" %}This is used in special cases for cross-site data calls, but it is usually an advanced usage that does not need to be specified manually.In a multi-site or multi-language environment, AnqiCMS will intelligently handle it for you.