How to use AnQiCMS template tags to retrieve and display the system configuration information of the website?

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

Where is the system settings of AnQiCMS?

First, let's understand how these system configuration information is managed in the background.In the Anqi CMS backend management interface, you can enter the 'Global Function Settings' page under 'Backend Settings' via the navigation menu.Here are gathered the core configuration items of the website, such as:

  • Website Name: Usually displayed in the browser title, header, and other locations.
  • Website Logo: The brand logo of the website.
  • Home Page Address: The root URL for accessing the website.
  • Mobile end addressIf a separate mobile site is enabled, this configuration will be available.
  • Template static file addressUsed to load CSS, JavaScript, images, and other static resources.
  • Website registration number: Information in accordance with legal requirements for filing.
  • Copyright content: Display the copyright statement at the footer.
  • Site Language: The default language setting of the website.
  • Custom parameter: Additional configuration items can be flexibly added according to your business needs.

Central management of these settings ensures consistency of website information and greatly reduces the workload of manually modifying template files.When you update this information in the background, the front-end page will immediately synchronize and display the latest content.

Core:systemUsage of template tags.

The key to obtaining and displaying these system configuration information in AnQiCMS templates issystemTemplate tags. The design of this tag is very intuitive, and its basic syntax is as follows:

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

or, if you just want to output the value of a field directly, 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, convenient for multiple references or complex processing in subsequent template logic.
  • name="字段名称"Is a required parameter, used to specify the specific system configuration item you want to retrieve. Here, the 'field name' is the English identifier for each configuration item in the background 'Global Function Settings', for exampleSiteName/SiteLogoetc.
  • If you have deployed multiple sites and need to retrieve the system configuration for a specific site, you can addsiteIda parameter to specify the site ID, for example{% system with name="SiteName" siteId="2" %}This parameter is usually not required in most single-site scenarios.

Obtaining and displaying common system configuration information.

Next, let's look at some common examples to see how you can 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 identity, usually displayed in the<title>tag or the prominent position in the header of the web 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 ways to obtain the website name: one is to access it directly throughsystemtag output, and the other is to assign it first towebsiteNameUse the variable again. 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 also addedifDetermine to ensure that the Logo image path exists before rendering<img>Tags to avoid displaying broken images.

3. Get the home page address of the website (BaseUrl)

When building internal links in a template, the home page address of the website is the foundation. 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. Reference 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 and adapt 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 it usually links 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 a common content. If the copyright information configured on the back end may contain HTML tags (such as bold, links), don't forget to usesafeA filter to ensure that 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>Set in the labellangattribute is important for multilingual support and SEO.

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

8. Call custom parameters

AnQiCMS's 'Global Function Settings' allows you to add custom parameters. If you create a named parameter calledHelpUrlThe custom parameter is used to store the link to the help page, which can be called in the following way:

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

Through these examples, you can seesystemHow template tags can help you easily retrieve 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.

Frequently Asked 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. First, please check if you have correctly uploaded and configured the 'website logo' image in the background 'global feature settings'.If the backend is not set, the tag naturally cannot obtain the value.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, you also need to ensure that the link is valid.In some cases, you may need to manually clear the browser cache to ensure the latest resources are loaded.

Q2: Can I get the information from the "Contact Information Settings" or "Homepage TDK Settings" in the background? 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 special template tags for better organization and management.For example, you can use{% 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 general system parameters in the "Global Function Settings", and more specific information is provided by the corresponding