How to call and display the global configuration information such as the website name, Logo, etc. in the Anqi CMS template?

As an experienced CMS website operation person, I am well aware of the importance of the global configuration information of the website, such as the website name and Logo, for the unified display of brand image and user recognition.In AnQi CMS, these core information is unifiedly managed, and with the concise and efficient template tag mechanism, it allows operators to easily call and display on various pages of the website.

Management of website global configuration information in AnQi CMS

The website's global configuration information is concentrated in the 'Global Function Settings' module of the background of Anqi CMS.These settings include the name of the website, Logo image, record number, copyright information, and various basic addresses of the website (such as the homepage address, mobile version address, etc.).Through this unified interface, you can easily modify and manage these key information, ensuring that the website presents a consistent brand image and basic data under different access scenarios.

Core tags for calling system global configuration information in the template

In the template system of Anqi CMS,systemTags are the special tools used to access these global configuration information. It allows you to quickly retrieve and display the corresponding values by specifying the names of configuration items.

Call syntax:

{% system 变量名称 with name="字段名称" %}

Among them:

  • 变量名称auto is an optional parameter, used to assign the obtained value to a temporary variable, which is convenient for multiple references in the template or for logical judgments.If not specified, the tag will directly output the corresponding value.
  • name="字段名称":is a required parameter, used to specify the name of the configuration item you wish to retrieve. These names correspond to the English identifiers of each configuration item in the background "Global Feature Settings".

The call and display of the website name

The website name is the facade of the website, usually displayed on the<title>Tags, header navigation, and footer copyright statements. BysystemLabel, you can easily present it in the template.

For example, to display the website name in the page title and combine it with the page's own TDK (Title, Description, Keywords) tags, it is usuallytdkLabels for unified management.tdkTagsTitleFields can be configured to include the website name suffix.

<title>{% tdk with name="Title" siteName=true %}</title>

This code will intelligently retrieve the title of the current page and base on it.siteName=trueThe settings, automatically appended at the end of the title with the website name you configured in the "Global Feature Settings" backend.

If you only need to display the website name independently at a specific position on the page (such as the footer), you can call it like this:

<div>欢迎访问:{% system with name="SiteName" %}</div>

Or assign it to a variable:

{% system currentSiteName with name="SiteName" %}
<div>当前网站名称是:{{ currentSiteName }}</div>

Calling and displaying the website logo

The website logo is the core element of brand visual recognition. In the Anqi CMS, you can upload logo images on the backend and throughsystemLabel gets its path and then embeds it into the HTML,<img>the tag.

For example, to display the logo image in the website header:

<a href="{% system with name="BaseUrl" %}">
    <img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
</a>

This code not only calls the URL of the Logo image, but also cleverly utilizesSiteNameAs the imagealtattribute values, which are crucial for search engine optimization (SEO) and accessibility.BaseUrlEnsure that the website home page is correctly navigated to after clicking the Logo.

Invocation of other commonly used global configuration information

In addition to the website name and Logo, there are many other globally useful configuration information in the template:

  • Website filing number (SiteIcp)It is usually displayed at the footer of the website and can link to the filing query platform.
    
    <p>
        <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a>
    </p>
    
  • Copyright content (SiteCopyright):Used to display the website copyright statement.
    
    <div>{% system with name="SiteCopyright"|safe %}</div>
    
    Here usage|safeThe filter is used because the copyright information may contain HTML entities or tags, to prevent them from being escaped.
  • Website Home Address (BaseUrl)English: : Used to build an absolute link, ensuring that the home page can be correctly returned on any page.
    
    <a href="{% system with name="BaseUrl" %}">网站首页</a>
    
  • Template Static File Address (TemplateUrl)It is very useful to refer to the built-in CSS, JavaScript, or other static resources.
    
    <link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
    <script src="{% system with name="TemplateUrl" %}/js/main.js"></script>
    
    It ensures that even if the website is deployed in a subdirectory or CDN, the path to static resources can be correctly resolved.
  • Site language (Language):Used to set the language attribute in HTML tags, which helps international websites and search engines understand the page language.
    
    <html lang="{% system with name='Language' %}">
    

Call custom global parameters

If you add a custom parameter, such as a parameter named “Hotline” (hotline), in the "Global Feature Settings" in the background, you can also usesystemLabel it to call it:

<div>客服热线:{% system with name="Hotline" %}</div>

This will directly output the value you have set for the 'Hotline' field in the background.

**Practical Tips and Considerations

  • UniformityUnified these global configuration information in the background management, and throughsystemLabel invocation can ensure that the website maintains a high degree of consistency in both visual and content.Once the configuration changes, it only needs to be modified once in the background, and all calls to this tag on the entire site will be automatically updated, avoiding the麻烦和潜在错误 of manually modifying template files.
  • Ease of maintenance:This calling method makes the template code more concise and readable, separates content from display logic, and improves the maintenance efficiency of the website.
  • SEO-friendly:Properly use the website name as the logo.altText, setting the website language attribute, ensuring that the record information is displayed, and other settings all help to improve the website's SEO performance.
  • Consider caching.In some cases, especially for static resources such as Logo images, if the latest version is not displayed immediately after the update, it may be necessary to clear the browser cache or CDN cache.For the cache of the Go program itself, the 'Update Cache' function in the Anqi CMS backend can help refresh the data at the system level.
  • Multi-site compatibilityIf you have enabled the multi-site management feature of Safe CMS and need to call the configuration information of a specific site (not the current site),systemLabels are supportedsiteIdParameters, allowing you to precisely control the source of the data obtained.

By skillfully applyingsystemLabels and the "Global Function Settings" backend, you can efficiently manage and display the core information of the website, providing users with a consistent and professional browsing experience.

Common Questions and Answers (FAQ)

1. I modified the website Logo image in the "Global Function Settings" on the backend, but the Logo on the frontend page did not update. Why is that?This is usually caused by browser cache or CDN cache.You can try clearing the browser cache, or if the website uses a CDN service, you also need to refresh the CDN cache.Moreover, the 'Update Cache' feature of the Anqi CMS backend can also help refresh the system-level data cache.

2. How to add some global information that is not included in the default system settings, such as the company's Facebook homepage link?You can find the "Custom Parameter Settings" area in the "Global Function Settings" page of the AnQi CMS backend.Click to add custom parameters, fill in the parameter name (such as “FacebookUrl”), parameter value (your Facebook homepage link) and remarks.{% system with name="FacebookUrl" %}Call the Facebook link you have set.

3. Can I call another site's Logo or website name in a template of a site in a multi-site secure CMS environment?OK.systemThe label supports an optional parametersiteIdIf you know the ID of the target site (which can be viewed in the "Multi-site Management" section of the backend), you can call it in the template like this:{% system with name="SiteLogo" siteId="目标站点ID" %}Thus, retrieve and display the logo of the specified site.