As an experienced website operation expert, I know that the stable operation of the website is of great importance, but sometimes, due to reasons such as maintenance, upgrading, or data migration, the website has to temporarily close its doors.How to gracefully convey information to visitors during a shutdown, ensuring a good user experience while effectively managing expectations, is a detail every operator needs to pay attention to.AnQiCMS (AnQiCMS) provides a flexible mechanism in this regard, allowing us to easily cope with it.
Today, let's delve into how to set tags through the system settings in AnQi CMS{% system %}ofSiteCloseTipsThe field cleverly judges whether the website is in a closed state and displays a friendly prompt to the user.
Understand the closed-site mechanism of Anqi CMS.
In the Anqi CMS backend management interface, you can find the option 'Website Status' under 'Global Feature Settings' in the 'Backend Settings' menu.When you set the website status to 'closed', the system will prompt you to fill in the 'closed notice' content.This 'shutdown prompt' is the main character of today -SiteCloseTips.
From a system design perspective, Anqi CMS does not directly provide a namedSiteStatusThe boolean value clearly indicates whether the website is closed. However, through our deep understanding of content operation and template tags, we can findSiteCloseTipsWhether a field exists or the length of its content is actually a valid basis for determining whether a website is closed. Simply put, ifSiteCloseTipsThe field contains specific text content, which means that the website is in a shutdown state, and this text is what needs to be displayed to the user;If this field is empty, the website will run normally. This design concept allows website operators to switch the website status without additional operations, simply by editing the prompt content, which is very efficient.
Determine the status of a closed website in the template and display a prompt
The Anqi CMS uses a syntax similar to the Django template engine, with system setting tags{% system %}It is the core tool for obtaining background configuration information. To obtainSiteCloseTipsThe content, we just need to call it in the template.
Now, let's see how to use it in the website template based onSiteCloseTipsThe content to judge and display the shutdown prompt. Usually, we would place this judgment logic in the public header of the website (such asbash.htmlOr in the main layout file, so that the prompt can be seen in time whenever the user visits any page.
Here is a concise and practical template code example that can help you achieve this function:
{%- system siteCloseMessage with name="SiteCloseTips" %}
{%- if siteCloseMessage %}
<div class="site-closure-notification" style="background-color: #f8d7da; color: #721c24; padding: 10px 20px; text-align: center; border-bottom: 1px solid #f5c6cb;">
<p>{{ siteCloseMessage|safe }}</p>
</div>
{%- endif %}
Let's parse the meaning of this code line by line:
{%- system siteCloseMessage with name="SiteCloseTips" %}This line of code is the standard usage of the Anqi CMS template tag. It callssystemthe tag and specifies the field name we want to retrieve isSiteCloseTips. The content obtained will be assigned to a variable namedsiteCloseMessagethe variable. Here{%-is to remove the blank lines before the tag to make the generated HTML code cleaner.{%- if siteCloseMessage %}: This is a conditional judgment statement. As we discussed earlier, ifsiteCloseMessageA variable contains any content (i.e., its string length is greater than 0), then this condition will be considered true, and the code block within it will be executed. Conversely, ifSiteCloseTipsthe background is empty, thensiteCloseMessageWill also be empty, the condition is false, the shutdown prompt will not be displayed.<div class="site-closure-notification" ...>: This is a standard HTMLdivAn element used to wrap shutdown prompt information. I have added some inline styles to make it look like a prominent warning banner, and you can customize the style according to your website.<p>{{ siteCloseMessage|safe }}</p>: Here, we display the content obtained from the backgroundsiteCloseMessage. It is worth noting that,|safeThe filter plays a crucial role here. Due toSiteCloseTipsOperators are allowed to input rich text containing HTML tags (such as bold, links, etc.). If output directly, these HTML codes may be escaped by the browser and cannot be displayed correctly.|safeThe filter's role is to inform the template engine that this content is safe, no need for HTML escaping, and can be parsed and displayed directly as HTML code.{%- endif %}Closed conditional judgment statement, the same was used-%}To remove trailing blank lines.
By placing this code on your website,bash.html(Public header) or in the top layout file, regardless of the page the user visits, as long as the website is in closed station status andSiteCloseTipsThere is content, and this prompt banner will be prominently displayed at the top of the page.
**Practice and Advanced Thinking
- The Art of Prompt Content:Writing
SiteCloseTipsAlways strive for brevity, clarity, professionalism, and a human touch.Inform the user of the closure reason, the expected recovery time (if possible), and any necessary alternative contact methods.For example: 'The website is undergoing emergency maintenance and is expected to be restored within 2 hours.'Sorry for the inconvenience, please forgive me! - User Experience First:Even if the site is closed, try to minimize the impact on users. In addition to displaying prompts, you can also consider adding a link to a specific page (such as customer service contact information or the latest announcements) to provide more help.
- Combination with a dedicated landing page:Anq CMS provides by default:
errors/close.htmlAs a dedicated site closure prompt page. When you directly set the "site status" to "closed" in the "global function settings" backend, the system will automatically render and jump to this dedicated closed site page.We pass through{% system %}Tag judgmentSiteCloseTipsThe way, it is more suitable for situations where the website is still accessible, but needs to highlight a notification (such as a module maintenance, rather than a complete site shutdown), or aserrors/close.htmlThe source of the page content. You can choose the most suitable implementation method according to your actual needs, even toSiteCloseTipsinject the content directly intoerrors/close.htmlthe page to achieve unified content management. - SEO consideration:For long-term closures, it is recommended to understand the settings of HTTP status codes. Although template-level judgments mainly focus on user experience, from an operational perspective, ensure that search engines receive the correct
503 Service UnavailableStatus codes can effectively avoid the website's weight from being damaged. However, this is usually a configuration at the server or CMS core level, not something that can be directly controlled by template tags.
Summary
The Anqi CMS, with its flexible template engine and customizable backend settings, allows website operation