How to get and display the system configuration information of the website through AnQiCMS template tags?

In the Anqi CMS, the system configuration information of the website is the foundation for website operation, including the website name, Logo, filing number, address, and other core data.This information is usually dynamically displayed on various pages of the website (such as the header, footer, contact us page, etc.) to maintain consistency.To facilitate efficient management and display of this information by template developers and content operators, AnQiCMS provides a concise and powerful template tag that allows you to flexibly obtain and display the system configuration of the website.

Where is the system settings of AnQi CMS?

Firstly, let's understand how these system configuration information is managed in the background.In the background management interface of Anqi CMS, you can enter the "Global Function Settings" page under "Background Settings" through the navigation menu.

  • Website Name:usually displayed in the browser title, header, and other locations.
  • Website Logo:the brand logo of the website.
  • [en]Home page address of the website.:the root URL of the website visited.
  • [en]Mobile end address:If the independent mobile site is enabled, this configuration will be present.
  • Template static file address:Used to load CSS, JavaScript, and images, etc., static resources.
  • Website filing numberUsed for information that complies with legal filing requirements.
  • Copyright content:Display the copyright statement at the footer.
  • Site language:The default language setting of the website.
  • Custom Parameters:Additional configuration items that you can flexibly add according to business needs.

These settings are centrally managed, ensuring consistency of website information and greatly reducing the workload of manually modifying template files.When you update this information in the background, the front-end page will immediately display the latest content.

Core:systemUsage of template tags

In AnQiCMS templates, the key to getting and displaying these system configuration information issystemtemplate tags. The design of this tag is very intuitive, and its basic syntax is as follows:

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

Alternatively, if you simply want to output the value of a certain field, you can omit it.变量名称:

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

Here:

  • 变量名称is an optional parameter that allows you to assign the obtained configuration value to a custom variable for convenient multiple references or complex processing in subsequent template logic.
  • name="字段名称"This is a required parameter, used to specify the specific system configuration item you want to retrieve. The 'field name' here is the English identifier for each configuration item in the 'Global Function Settings' on the backend, for example,SiteName/SiteLogoetc.
  • If you have deployed multiple sites and need to retrieve the system configuration for a specific site, you can do so by addingsiteIdto specify the site ID, for example{% system with name="SiteName" siteId="2" %}In most single-site scenarios, this parameter does not need to be filled in.

Obtaining and displaying common system configuration information

Next, let's look at some common examples to see how to flexibly use your AnQiCMS templatesystemtags to retrieve and display these system configuration information.

1. Display the website name (SiteName)

The website name is an important identifier for the website, usually displayed in a prominent position in the<title>header or at the top of the page.

<title>{% tdk with name="Title" siteName=true %}</title> {# 结合 TDK 标签获取标题并带上网站名称 #}
{# 或者直接获取网站名称 #}
<h1>欢迎访问:{% system with name="SiteName" %}</h1>
{# 赋值给变量再使用 #}
{% system websiteName with name="SiteName" %}
<p>我们的网站是:{{ websiteName }}</p>

In the above example, we demonstrated two methods for obtaining the website name: one is to obtain it directly throughsystemlabel output, and the other is to assign it firstwebsiteNameThe variable is reused. At the same time, we also saw how to combinetdkThe tag automatically generates a page title containing the website name.

2. Display the website Logo (SiteLogo)

The website logo is a symbol of the brand image. You can place the logo at the header and combine it with the website name asaltattributes to enhance SEO and accessibility.

<a href="{% system with name="BaseUrl" %}">
    <img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />
</a>
{# 赋值给变量再使用,并确保 Logo 存在才显示 #}
{% system siteLogoPath with name="SiteLogo" %}
{% system siteDisplayName with name="SiteName" %}
{% if siteLogoPath %}
    <img src="{{ siteLogoPath }}" alt="{{ siteDisplayName }}" class="header-logo" />
{% endif %}

Here we have also addedifdetermine, to ensure that the Logo image path exists before rendering<img>labels, to avoid displaying broken images.

3. Get the website home page address (BaseUrl)

When building internal links in the template, the home page address of the website is the basis. UseBaseUrltags to ensure the correctness of the link, even if the domain name of the website changes, it only needs to modify the background configuration.

<nav>
    <a href="{% system with name="BaseUrl" %}">首页</a>
    {# ...其他导航链接... #}
</nav>

4. English template static file address (TemplateUrl)

Your template may depend on specific CSS stylesheets, JavaScript scripts, or image resources.TemplateUrlLabels can help you build the correct static file path, adapting to different deployment environments.

<link rel="stylesheet" href="{% system with name="TemplateUrl" %}/css/style.css">
<script src="{% system with name="TemplateUrl" %}/js/main.js"></script>

5. Display the website filing number (SiteIcp)

For websites that need to display filing information,SiteIcpThe label can be conveniently output in the footer and other locations, and will usually link to the Ministry of Industry and Information Technology website.

<p>
    <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">{% system with name="SiteIcp" %}</a>
</p>

6. Display copyright content (SiteCopyright)

The copyright statement at the bottom of the website page is common content. If the copyright information configured in the background may contain HTML tags (such as bold, links), don't forget to usesafeFilter to ensure content is parsed correctly rather than escaped.

<footer>
    <p>{% system copyrightInfo with name="SiteCopyright" %}{{ copyrightInfo|safe }}</p>
</footer>

7. Set the site language (Language)

in the HTML document's<html>setting in the labellangattribute is important for multilingual support and SEO.

<html lang="{% system with name='Language' %}">
{# ... #}
</html>

8. Call custom parameter

AnQiCMS's “Global Feature Settings” allows you to add custom parameters. If you create a namedHelpUrlThe custom parameter for storing the help page link, which can be called in the following way:

<a href="{% system with name="HelpUrl" %}">帮助中心</a>

Through these examples, you can see:systemHow template tags help you easily obtain and display various system configuration information in AnQiCMS templates.This not only improves the flexibility and maintainability of the template, but also makes website operation more efficient.

Common Questions (FAQ)

Q1: Why do I call{% system with name="SiteLogo" %}After, the front-end image did not display?

A1:This usually has several reasons.Firstly, please check if you have correctly uploaded and configured the "website logo" image in the "Global Function Settings" on the backend.If the background is not set, the tag cannot obtain the value naturally.Next, check if the image path is correct, and whether the image file on the server exists and is accessible.If the image is a remote link, it also needs to ensure that the link is valid.In some cases, you may need to manually clear the browser cache to ensure that the latest resources are loaded.

Q2: Can I get the information from the "Contact Information Settings" or "Home Page TDK Settings" in the template? They are also part of the system configuration.

A2:Of course you can.Although this information also belongs to the system-level configuration of the website, AnQiCMS provides dedicated template tags for better organization and management.{% contact with name="Cellphone" %}To get the contact phone number, use{% tdk with name="Keywords" %}To get the home page keywords. The article introducessystemTags are mainly used for the general system parameters in the "Global Function Settings", and more specific information is provided by the corresponding