During the operation of the website, the filing number and copyright information are indispensable elements. They not only concern the legality of the website but also reflect the professionalism of the website.For websites built using Aanqi CMS, it is a very basic but important skill to flexibly call and format the display of this information in the template.

It is fortunate that AnQi CMS provides a simple yet powerful template tag system, making it exceptionally easy to call the website filing number and copyright information.Next, let's see how to achieve this goal in the template of AnQi CMS.

First, set up the filing number and copyright information in the background

Before starting the template operation, you need to ensure that this information has been correctly entered in the backend of the security CMS.通常,这些全局性的网站信息都可以在“后台设置”下的“全局功能设置”中找到。

You will see the input boxes for 'Record Number' and 'Copyright Information' on the settings page.Here, simply fill in your website record number (for example, "Beijing ICP备案号12345678All Rights Reserved.”)。The company will properly save these data and prepare them for the front-end template.

Template calls the website filing number

The AnqiCMS template follows the syntax similar to the Django template engine, using double curly braces{{变量}}To output variables, use{% 标签 %}Perform logical operations. For system-level configuration information of the website, we mainly rely onsystemLabel.

To call the record number, you can usesystema tag to specifynameparameter asSiteIcp. The most direct way to call is:

{% system with name="SiteIcp" %}

So, the registration number you filled in the background will be displayed directly on the page.

But usually, the filing number needs to be linked to the Ministry of Industry and Information Technology filing management system query page for users to verify. At this time, we can<a>Tag this tag within the label and set the corresponding link and attributes:

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

Here we added the link:rel="nofollow"Properties, this is a common SEO practice, telling search engines not to follow this link because it usually does not involve content recommendations; at the same time,target="_blank"Ensure that the user clicks to open in a new tab, improving the user experience.

Call and format the display of copyright information in the template.

Copyright information usually includes the current year, website name, and specific statements. UsesystemTags can also easily obtain the copyright content set in the background.SiteCopyrightThe field is used to store this information:

{% system with name="SiteCopyright" %}

If the copyright information does not include the year or you want the year to be dynamically displayed as the current year, then you can combinenowtags to achieve this.nowTags can help us obtain the current date and time. By specifying a format string, we can extract the year. For example, to get a four-digit year, you can use"2006"This format string (this is a special reference time in the Go language, representing a fixed date).

Therefore, a common copyright statement combination might be like this:

<p>
    &copy; {% now "2006" %}
    {% system with name="SiteName" %}
    {% system with name="SiteCopyright" %}
</p>

Here,{% now "2006" %}It will automatically output the current year.{% system with name="SiteName" %}It will call the website name you set in the background.

It is noted that if you enter HTML code in the "Copyright Information" section on the backend, such as including a link or other style tags, in order to ensure that these HTML codes are correctly parsed rather than displayed as plain text, you need to pass the variable calling it through|safeFilter processing. For example, if we giveSiteCopyrightDefined a variablesiteCopyright:

{% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}

Pass|safeFilter, the safety CMS template engine will considersiteCopyrightThe content is safe HTML and is rendered directly to the page.

Comprehensive example: the record number and copyright information of the website footer

Combining the method of calling the record number and copyright information, we can easily construct a complete website footer information block:

<footer>
    <div class="container">
        <p class="icp-info">
            <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">
                {% system with name="SiteIcp" %}
            </a>
        </p>
        <p class="copyright-info">
            &copy; {% now "2006" %} {% system with name="SiteName" %}.
            {% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}
        </p>
    </div>
</footer>

Place this code in the footer part of your template file (for examplepartial/footer.htmlor directly in thebash.html中),网站备案号和版权信息就会以整洁、规范的方式显示出来,并且年份会随时间自动更新。

The template system of AnQi CMS is intuitive and flexible, greatly simplifying the management and display of website content.Through simple tags, you can easily master the key information of the website, making content operation more efficient.


Common Questions (FAQ)

  1. 问:Why does the record number/copyright information I set not display on the website front end?

    • Answer:First, please check if your template file uses it correctly when this situation occurs.{% system with name="SiteIcp" %}and{% system with name="SiteCopyright" %}Such a label.If the tag is used correctly, please try to click the 'Update Cache' button in the Anqi CMS backend, refresh the system cache, and then refresh the page.Sometimes browser cache may also cause display delay, you can try to clear the browser cache or access in incognito mode.
  2. 问:If my copyright information contains HTML code (such as a link), how can I ensure that it is rendered correctly rather than displayed as plain text?

    • Answer:If the "Copyright Information" set in the background contains HTML code, in order for these codes to be parsed and rendered by the browser on the front end, you need to add an extra tag call after usingsystem标签调用后,再额外添加|safeFilter. For example, you can first assign the copyright content to a variable{% system siteCopyright with name="SiteCopyright" %}and then use it when outputting{{ siteCopyright|safe }}. This way, HTML content will not be escaped, but displayed as expected.
  3. 问:除了显示当前年份,我还可以用Englishnow标签格式化显示其他日期或时间信息吗?

    • Answer:Of course you can.nowLabels support Go language's date formatting rules, you can use different format strings to display dates and times as needed. For example,{% now "2006-01-02" %}it will display the full year, month, and day,{% now "15:04" %}It will display the current hour and minute. This provides you with great flexibility to meet various date and time display requirements.