How to accurately call the system settings (such as website name, Logo) in the template for display?

As users of AnQi CMS, we often need to ensure that the core information of the website, such as the website name, Logo, filing number, etc., is displayed accurately and correctly on each page of the website.This concerns the unity of brand image, and also directly affects user experience and search engine optimization.AnQi CMS, with its efficient architecture based on the Go language and similar Django template engine syntax, makes the invocation of these basic information intuitive and flexible.

Next, let's explore how to easily call and display these important system settings in the Anqi CMS template.

Use cleverlysystemTags, get core website information

The AnQi CMS provides us with a very convenient and powerful tool -systemThe tag is specifically used to obtain various system-level information configured in the background "Global Function Settings".Whether it is the name of the website, Logo address, or filing number, copyright statement, it can be called through it in the template.

UsesystemThe basic format of tags is as follows:{% system 变量名称 with name="字段名称" %}. Among them,"字段名称"The name of the specific system setting item you want to call. If you do not need to assign the obtained value to a variable for subsequent processing, you can also omit it.变量名称Let it output the result directly.

Let's understand its actual application through some specific examples.

Display of the site name (SiteName)

The website name is the core of brand recognition, and it usually appears in prominent positions such as the page title, header, etc.In the AnQi CMS backend, you will find the 'Website Name' item under the 'Global Function Settings'.

In the template, you can call it like this:

<title>{% system with name="SiteName" %} - 您的网站副标题</title>

If you want to store the website name in a variable before using it, you can write it like this:

{% system siteName with name="SiteName" %}
<h1 class="site-title">{{ siteName }}</h1>

In this way, no matter how you modify the website name in the background, the front-end page will automatically update without changing the template code, greatly improving maintenance efficiency.

The call to the website logo (SiteLogo)

The logo is the visual hammer of the website, carrying the brand image. After uploading the logo image in the "Global Function Settings", you can easily refer to its address in the template:

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

Here we not only called the image address of the Logo, but also combined the website name as the image'saltProperties, this is very beneficial for the website's SEO and accessibility. At the same time, we have also called the website's homepage address(BaseUrl)to ensure that clicking on the logo can return to the homepage.

The display of the website filing number (SiteIcp)

For domestic websites, the filing number is an essential piece of information, usually located at the bottom of the website. Anqi CMS also provides a convenient way to call it:

<p>
    <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">
        {% system with name="SiteIcp" %}
    </a>
    &copy; {% now "2006" %} 版权所有
</p>

Here we also used{% now "2006" %}This auxiliary label will automatically display the current year, keeping your copyright information up to date.

The call to copyright information (SiteCopyright)

The copyright statement at the bottom of the website often contains some HTML formatted content, such as links or special symbols. To ensure that this content can be correctly parsed by the browser, we need to use|safeFilter:

{% system siteCopyright with name="SiteCopyright" %}
<div class="site-footer-copyright">
    {{ siteCopyright|safe }}
</div>

|safeThe filter tells the template engine that this content is safe, does not require HTML entity encoding, and can be output directly as HTML code.

The use of the template static file address (TemplateUrl)

When developing templates, we often need to refer to CSS stylesheets, JavaScript scripts, images, and other static resources.TemplateUrlThe tag can obtain the root path of the static resources in the current template folder, making the resource reference very flexible, even if the template is changed, it is not necessary to manually modify a large number of paths.

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

This way, your style and script files can be loaded correctly.

Flexible calling of custom system parameters

The strength of AnQi CMS lies in its high customizability.In addition to the preset fields, you can also add custom parameters in the "Global Function Settings" backend, such as the company's WhatsApp contact information, special help page links, etc.

Assuming you have added a custom parameter named 'Customer Service Phone' in the 'Parameter Name' field in the backgroundServicePhoneThe customer service phone number you entered can be called in the template like this:

<div>客服电话:{% system with name="ServicePhone" %}</div>

This allows you to extend the display information of the website front-end according to your business requirements without modifying the core code.

Summary

Of Security CMSsystemTags provide a graceful way to centrally manage and call the basic information of the website.With it, you can easily display the website name, Logo, filing number, copyright information, and so on in the template, and it can also flexibly expand custom parameters to meet various personalized needs.Mastering these skills, you will be able to manage your Anqi CMS website more efficiently and flexibly, ensuring the accuracy and consistency of information display.

Frequently Asked Questions (FAQ)

1. I added a custom parameter in the background "Global Function Settings", but why can't it be called in the template?

Please check what you aresystemin the tag usednameIs the attribute consistent with the "parameter name" set in the background. For example, if the parameter name set in the background isServicePhone, then the template should use{% system with name="ServicePhone" %}Please note that the case is important as tags are usually case-sensitive.Finally, after modifying the background settings, it is recommended to manually click the 'Update Cache' button at the top of the background to ensure that the latest configuration is correctly read by the front-end.

2. Why doesn't my website's logo display after calling it, what could be the reason?

There are some common reasons:

  • Logo not uploaded or path error:Please log in to the "Global Function Settings" page on the backend and confirm whether the Logo image has been successfully uploaded and the Logo address looks correct.
  • File permission issue: Make sure the Logo image is located on your server,/uploadsthe directory and its subdirectories have the correct read and write permissions.
  • Cache problem:Clear browser cache and security CMS backend cache (by clicking the "Update Cache" button), sometimes old cache can cause images not to display.
  • Network issue: Check if the image address can be accessed directly through the browser, and confirm that the server firewall or CDN configuration is correct.

3. I have multiple AnQi CMS sites, can I call the system settings of other sites in one template?

Yes.systemThe tag supports onesiteIdThe parameter is used to specify which site's system settings to retrieve. If you create multiple sites through the "Multi-site Management" backend, each site will have a uniqueID. You can call it like this in the template:{% system siteName with name="SiteName" siteId="2" %}{{siteName}}here,siteId="2"It represents the website name of the site with ID 2. Please replace it with your actual site ID.