During the operation of the website, the filing number and copyright information are indispensable elements, which not only concern the legality of the website but also reflect the professionalism of the website.For a website built with Anqi CMS, it is a basic but important skill to call and format these information flexibly in the template.
Luckyly, Anqi CMS provides a simple and powerful template tag system, making the calling of website filing number and copyright information extremely easy.Next, let's take a look at how to achieve this goal in the Anqi CMS template.
First, set up the filing number and copyright information in the background
Before starting the template operation, you need to make sure that this information has been correctly entered in the Anqi CMS backend.These global website information can usually be found under the "Global Function Settings" in the "Background Settings".
You will see the input boxes for 'Record number' and 'Copyright information' on the settings page.Here, simply fill in your website filing number (e.g. "Beijing ICP preparation No. 12345678") and copyright statement (e.g. "© 2023 Your Company Name. All Rights Reserved.").The Anqi CMS will properly save these data and prepare it for the front-end template call.
The website registration number is called in the template
The template of AnQi CMS follows the syntax similar to Django template engine, using double curly braces{{变量}}Use to output variables,{% 标签 %}Perform logical operations. We mainly rely on system-level configuration information for the website.system.
To call the record number, you can use.systemlabel and specifynameparameters forSiteIcpThe most direct way to call is:.
{% system with name="SiteIcp" %}
This will directly display the record number you filled in the background 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>Embed this tag 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 linkrel="nofollow"An attribute, this is a common SEO practice, it tells the search engine not to follow this link, as it usually does not involve content recommendation; at the same time, addingtarget="_blank"Make sure the user opens in a new tab after clicking, enhancing the user experience.
Call and format the display of copyright information in the template.
Copyright information typically includes the current year, the name of the website, and specific statements. UsesystemTags can also easily retrieve 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 displayed dynamically as the current year, then you can combinenowthe tag.nowTags can help us get 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 Go language, representing a fixed date).
Therefore, a common combination of copyright statements might be like this:
<p>
© {% 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 should be noted that if you enter HTML code in the "Copyright Information" section of the backend, such as a link or other style tags, in order to ensure that these HTML codes are parsed correctly rather than displayed as plain text, you need to pass the variable that calls it through|safeThe filter is processed. For example, if we giveSiteCopyrightdefined a variablesiteCopyright:
{% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}
By|safeThe filter, the template engine of Anqi CMS will thinksiteCopyrightThe content within is safe HTML, and it will be rendered directly onto the page.
An example of a comprehensive: website footer registration number and copyright information
By combining the calling methods of the registration number and copyright information, we can easily build 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">
© {% now "2006" %} {% system with name="SiteName" %}.
{% system siteCopyright with name="SiteCopyright" %}{{siteCopyright|safe}}
</p>
</div>
</footer>
Place this code at the bottom of your template file (for examplepartial/footer.htmlor directly inbash.htmlIn Chinese, the website filing number and copyright information will be displayed in a neat and standardized manner, and the year will be automatically updated over time.
The Anqi CMS template system is intuitive and flexible, greatly simplifying the management and display of website content.By using simple tags, you can easily control the key information of the website, making content operation more efficient.
Frequently Asked Questions (FAQ)
Why did I set the filing number/copyright information, but it didn't display on the website front end?
- Answer:If this happens, please first check whether your template file has used it correctly.
{% system with name="SiteIcp" %}and{% system with name="SiteCopyright" %}Such a label. If the label is used correctly, please try to click the "Update Cache" button in the Anqi CMS background, clear the system cache and refresh the page.Sometimes browser cache may also cause display delay, you can try to clear the browser cache or access in incognito mode.
- Answer:If this happens, please first check whether your template file has used it correctly.
Ask: 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
systemtags after calling the tag|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, the HTML content will not be escaped, but will be displayed as expected.
- 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
Ask: Can I also use labels to format other date or time information?
nowCan I format other date or time information using labels?- Answer:Of course you can.
nowThe tag supports 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 needs.
- Answer:Of course you can.