How to get and display the global information of the AnQiCMS system settings label `system`?

In website construction and daily operation, we often encounter situations where we need to display some global information, such as the website name, Logo, filing number, contact information, etc.This information runs through the entire website and needs to be consistent on multiple pages.systemTemplate tags.

KnowsystemTag: The key to obtain global information of the website

systemTags are like keys that can help you easily access and display various website global information configured in the background "Global Function Settings" within templates.You do not need to manually copy the code or worry about inconsistent information, just simply call it, AnQiCMS will automatically render the latest global settings for you.

Its basic usage is very intuitive:

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

There are two core parts in this that we need to understand:

  • name="字段名称"This is the most important part, specifying the specific global information you want to obtain. For example, if you want to obtain the website name, that is字段名称isSiteName; if you want to obtain the website logo, that isSiteLogoThese field names usually correspond to items in the backend settings 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 examplesiteNameIf 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,systemtags support ansiteIdParameters, allowing you to specify the information of a specific site. However, in most single-site cases, we usually do not need to set this parameter, as the tag will automatically retrieve the information of the current site.

Common global information and its retrieval methods

Now, let's look at how to use it through some specific examplessystemTags to retrieve and display common website global information:

  1. Website name (SiteName)This is the brand name of the website, usually displayed in the browser title bar, website header, and other locations.

    <title>{% system with name="SiteName" %}</title>
    <h1>欢迎来到 {% system with name="SiteName" %}</h1>
    
  2. Website Logo (SiteLogo)The visual identity of the website, generally appearing at the header.

    <a href="/">
        <img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
    </a>
    
  3. Website filing number (SiteIcp)If your website has a filing, 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>
    
  4. Copyright content (SiteCopyright) and the current yearA common footer copyright notice, usually including the current year. AnQiCMS provides a{% now "2006" %}tag for convenient access to the current year.

    <div>
        {% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}
        &copy; {% now "2006" %}. All Rights Reserved.
    </div>
    

    Here, we first assignSiteCopyrightto assign the content ofsiteCopyrightto a variable, and then use|safeFilter to ensure that the content can be parsed and displayed correctly even if it contains HTML code.

  5. Website Home Address (BaseUrl)This tag comes in handy when you need to get the root directory URL of the website.

    <link rel="home" href="{% system with name="BaseUrl" %}" />
    
  6. Template Static File Address (TemplateUrl)The CSS, JS, and images, etc., of the template are usually stored in a specific directory. UseTemplateUrlto help you build the correct path to static files.

    <link href="{% system with name="TemplateUrl" %}/css/style.css" rel="stylesheet">
    <script src="{% system with name="TemplateUrl" %}/js/main.js"></script>
    
  7. 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, which is usually used in HTML tags.langproperties.

    <html lang="{% system with name='Language' %}">
    
  8. Custom parameters (后台自定义设置的参数名)AnQiCMS allows you to add custom parameters in the "Global Function Settings" in the backend.These parameters can be your website's unique contact information, social media links, or any information you need to globally access.HelpUrl[en]You can call it like this: the custom parameter,

    <div>我们的帮助页面:<a href="{% system with name="HelpUrl" %}" target="_blank">点击这里</a></div>
    

[en]Integrate global information into the website.

PasssystemTags, we can easily call these global information at various parts of the website (such as header, footer, sidebar, etc.), thus ensuring the consistency and maintainability of the entire website. For example, a typical website footer may contain copyright information, filing number, and contact information, all of which can besystemTags andcontactLabel (used to obtain contact information) combination implementation:

<footer>
    <div class="container">
        <p>
            {% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}
            &copy; {% 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

systemTemplate tags are 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 operation work more efficient.


Common Questions and Answers (FAQ)

Q1: I have added a custom parameter in the "Global Function Settings" on the backend, how can I call it in the frontend template?A1: Very simple. Assume that you have added a custom parameter named "Social Media Link" in the background, and the parameter name is filled in asSocialMediaLinkand set the value. In the front-end template, you can use{% system with name="SocialMediaLink" %}to retrieve and display this value.

Q2: My website has enabled the multi-site management feature. I want to display the global information of another site in one of the site templates. Is it possible to do that?A2: Yes, it is possible.systemtag supportsiteIdParameters. You need to know the target site'ssiteId(usually visible on the multi-site management page in the backend), 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 doesn't the front-end page update immediately after I modify the global settings in the background?A3: This may be due to the system cache of AnQiCMS.You can try to clear the system cache.In AnQiCMS backend, there is usually an option like 'Update Cache' or similar, clicking it will refresh the cache, making the modified global settings take effect immediately.{% system ... %}Label.