How to output the background configuration system information in AnQiCMS template, such as the website name, Logo and filing number?

In the flexible world of AnQiCMS, elegantly presenting the system-level information configured in the backend to the website front end is a core skill that every website operator and template developer must master.As an experienced website operation expert, I fully understand that these seemingly trivial aspects are invaluable for enhancing brand image, optimizing user experience, and meeting regulatory requirements (such as the display of filing number).Today, let's delve into how to output these valuable background information in a natural and smooth way in the AnQiCMS template.

AnQiCMS, as an enterprise-level content management system developed based on the Go language, is known for its high efficiency, customizable, and easily scalable features, providing strong support for small and medium-sized enterprises and content operation teams.The template engine is cleverly designed, drawing on the advantages of Django templates, making it easy for operators who are not very familiar with Go language to smoothly handle the presentation of front-end content.

AnQiCMS Template Syntax Core Points

Variable output in AnQiCMS templates uses double curly braces{{ 变量名 }}The form of “auto” translation to “English”{% 标签 %}It is presented in the form.Understanding this is the first step in mastering the AnQiCMS template.The system information on the backend configuration, which is dynamically injected into our front-end page through this tag syntax.

Unveiling the “System Settings” tag:“systemThe power of “auto” translation to “English”

To output the system information configured in the AnQiCMS template backend, the key is to use a namedsystemThe powerful tag. This tag is specifically used to retrieve the various system-level parameters configured in the "Global Settings" of the AnQiCMS backend.

Its basic usage is very intuitive:{% system 变量名称 with name="字段名称" %}.

Here are thenameThe parameter is crucial, it corresponds to the unique identifier (field name) of each configuration item on the background "Global Settings" interface. For example, the field name corresponding to the website name isSiteNameThe website logo isSiteLogoThe record number isSiteIcp. By specifying these field names, you can accurately retrieve the corresponding information from the background. If there is no need to assign the result to a variable, it can also be output directly, for example{% system with name="SiteName" %}.

实战演练:轻松输出网站核心信息 (English)

Next, let's look at some specific examples to see how to embed common information such as website name, Logo, and filing number into your AnQiCMS template.

1. Display website name (SiteName)

The website name usually appears on the page<title>Tags within, and the header navigation of the website or other prominent positions. It is not only an important part of brand recognition, but also the foundation of SEO optimization.

You can call it like this in the template:

<title>{% system with name="SiteName" %}</title>
{# 如果想把网站名称赋给一个变量再使用,可以这么做 #}
{% system currentSiteName with name="SiteName" %}
<h1>欢迎来到 {{ currentSiteName }} 的官方网站</h1>

With this simple tag, no matter how you modify the site name in the background, the front-end will be updated in real time to maintain consistency of the information.

2. Embed Website Logo (SiteLogo)

The website logo is the visual symbol of the brand and an important manifestation of website personalization. Typically, the Logo will be<img>Label embedded in the form, and accompanied byaltProperties to enhance SEO and accessibility.

The following is a typical way to call the website logo:

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

Here we cleverly use the website name as the logo of thealtAttribute value, which not only increases semantics but also makes it easier for search engines to understand the content of the image.

3. Display the website record number (SiteIcp)

For websites operating in mainland China, the filing number is an essential compliance information, usually placed at the footer of the website.AnQiCMS similarly supports the unified management of this information in the background.

You can output the record number in the template like this:

<p>
    {# 备案号通常需要链接到工信部备案查询网站 #}
    <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">
        {% system with name="SiteIcp" %}
    </a>
    {# 您可以结合当前年份和版权信息,使页脚更完善 #}
    &copy; {% now "2006" %} 版权所有
</p>

This code not only outputs the background configuration of the filing number, but also automatically generates a link to the Ministry of Industry and Information Technology filing query website, and dynamically displays the current year, making your footer information both professional and compliant.

4. Flexible invocation of other system information and custom parameters

In addition to the above three items,systemTags can also obtain other preset information from the background "Global Settings", such as the website home page addressBaseUrl、Mobile End AddressMobileUrl、Copyright ContentSiteCopyrightetc.

It is worth mentioning that if you have customized additional parameters in the background "Global Settings", such as a parameter namedServiceHotlineCustomer Service Hotline, you can also access throughsystemLabel it easily to output:

{# 输出自定义的客服热线 #}
客服热线:{% system with name="ServiceHotline" %}
{# 如果ServiceHotline可能包含HTML,可以使用safe过滤器 #}
<p>{% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}</p>

This greatly enhances the flexibility and maintainability of the template, allowing you to adjust the important operational information of the website without modifying the code.

Summary

AnQiCMS's template mechanism provides great convenience for website operators. By flexibly utilizingsystemThe tags, you can seamlessly and dynamically display the key information such as the website name, Logo, filing number, etc. that you have configured on the backend on the front end of the website.This front-end and back-end separation configuration method not only ensures the consistency of website information, but also greatly improves the efficiency of content management.Master these basic skills and you will be able to better utilize AnQiCMS, building professional, efficient, and easy-to-maintain websites.


Common Questions (FAQ)

Q1: Why didn't the website name or Logo update immediately on the front page after I changed it in the AnQiCMS backend?

A1:

Q2: BesidessystemLabel, what other labels can be used in AnQiCMS to output the basic configuration information of the website?

A2:ExceptsystemLabel outside