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

As an Anqi CMS user, 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 all pages of the website.This concerns the consistency of the brand image as well as directly affects user experience and search engine optimization.Auto CMS benefits from its efficient architecture based on the Go language and syntax similar to Django's template engine, making 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 to get the core website information

English CMS provides us with a very convenient and powerful tool ——systemLabel.This tag is specifically used to retrieve various system-level information configured in the "Global Function Settings" in the background.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="字段名称" %}."字段名称"This is the specific system setting item name 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 directly output the result.

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

Website Name (SiteName) Display

The website name is the core of brand recognition and usually appears in prominent positions such as the page title and header.In 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 first and then use it, you can write it like this:

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

Through this method, 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 the maintenance efficiency.

调用网站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 logo image address, but also combined the website name as the image of thealtAttributes, this is very beneficial for the SEO and accessibility of the website. At the same time, we also called the website homepage address (BaseUrl), to ensure that clicking the logo can return to the homepage.

Website备案号(Site ICP)Display

For domestic websites, the filing number is an essential piece of information, usually located at the bottom of the website. The 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 use:{% now "2006" %}This auxiliary label, it will automatically display the current year, keeping your copyright information always up to date.

The call to the 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 and does not need to be HTML-escaped. It can be output directly as HTML code.

The application of TemplateUrl (template static file address)

When developing templates, we often need to refer to CSS style sheets, JavaScript scripts, or images, etc., as static resources.TemplateUrlThe label can obtain the root path of the static resources in the current template folder, making resource references very flexible. Even if the template is changed, there is no need 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>

So, 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 aforementioned fields, you can also add custom parameters in the 'Global Feature Settings' section of the 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 Number" in the "Parameter Name" field in the backgroundServicePhone,“Parameter value” should be filled in with your customer service phone number. Then you can call it in the template like this:

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

This allows you to extend the information displayed on the website front end according to business needs without modifying the core code.

Summary

Anqi CMS'ssystemTags provide an elegant way to centrally manage and invoke the fundamental information of the website.Through 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 security CMS website more efficiently and flexibly, ensuring the accuracy and consistency of information display.

Common Questions (FAQ)

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

Please check thesystemUsed in the tag:nameIs the attribute exactly 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" %}.At the same time, please note that the case matches, as labels are usually case-sensitive.Finally, after modifying the backend settings, it is recommended to manually click the 'Update Cache' button at the top of the backend to ensure that the latest configuration is correctly read by the frontend.

2. My website's Logo does not display after calling it, what could be the reason?

There are several common reasons:

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

3. I have multiple security CMS sites, can I call other sites' system settings in one template?

Yes, it can.systemThe tag supports asiteIdParameter used to specify which site's system settings to retrieve. If you have created multiple sites using 'Multi-site management' in the 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"Represents the website name of the site with ID 2. Please replace it with your actual site ID.