As a senior website operations expert, I know that the stable operation of the website is of paramount importance, but sometimes, for reasons such as maintenance, upgrades, or data migration, the website has to temporarily 'close its doors'.How to elegantly communicate information to visitors during the closure period, ensuring a good user experience while effectively managing expectations, is a detail that every operator needs to pay attention to.AnQiCMS (AnQiCMS) provides a flexible mechanism in this aspect, allowing us to deal with it easily.
Today, let's delve into how to set tags through the system settings in the Anqi CMS{% system %}ofSiteCloseTipsField, cleverly judge whether the website is in a shutdown state, and display a friendly prompt to the user.
Understand the closure mechanism of AnQi CMS
In the background management interface of AnQi CMS, you can find the option 'Website Status' under 'Global Function Settings' in 'Background Settings'.When you set the website status to "ClosedSiteCloseTips.
From the perspective of system design, Anqi CMS does not provide a direct namedSiteStatusThe boolean value clearly indicates whether the website is closed. However, through our deep understanding of content operation and template tags, we can find outSiteCloseTipsThe existence of a field or the length of its content is actually a valid basis for judging whether a website is closed. In simple terms, ifSiteCloseTipsIf the field contains specific text content, it means that the website is in a shutdown state, and this text is the prompt to be displayed to the user; if the field is empty, the website is operating normally.This design approach allows website operators to switch the website status without extra operation on the shutdown switch, just by editing the prompt content, which is very efficient.
Determine the closed status in the template and display a prompt
The CMS adopts syntax similar to Django template engine, with system setting tags{% system %}It is the core tool to obtain background configuration information. To obtainSiteCloseTipsThe content, we just need to call it in the template.
Now, let's see how to use the website template, according toSiteCloseTipsThe 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 accesses any page.
The following 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 security CMS template tag. It callssystemthe tag and specifies the field name we want to retrieveSiteCloseTips. The content retrieved will be assigned to a variable namedsiteCloseMessageHere is the{%-This is to remove the blank lines before the tags, making the generated HTML code cleaner.{%- if siteCloseMessage %}This is a conditional judgment statement. As discussed before,siteCloseMessageIf the variable contains any content (i.e., its string length is greater than 0), this condition will be considered true and the code block inside will be executed. Otherwise, ifSiteCloseTipsit is empty in the background, thensiteCloseMessageThis will also be empty, the condition is false, the shutdown prompt will not be displayed.<div class="site-closure-notification" ...>: This is a standard HTMLdivElement for wrapping the closed station 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 style.<p>{{ siteCloseMessage|safe }}</p>: Here, we display the content obtained from the backgroundsiteCloseMessageContent. It is worth noting,|safeThe filter plays a crucial role here. BecauseSiteCloseTipsAllow operators 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 function of the filter is to inform the template engine that this content is safe and does not require HTML escaping, and can be parsed and displayed directly as HTML code.{%- endif %}:Closed condition judgment statement, the same as used in English.-%}to remove trailing blank lines.
by placing this code on your website's English version.bash.html(Public header page) or top layout file, regardless of which page the user visits, as long as the website is in a closed station state andSiteCloseTipsThere is content, and this banner prompt will be prominently displayed at the top of the page.
**Practice and Advanced Thinking
- The Art of Prompt Content:Writing
SiteCloseTipsWhen, be sure to strive for brevity, clarity, professionalism, and humanity.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 urgent maintenance and is expected to be restored within 2 hours.'}]Sorry for the inconvenience, please understand! - User Experience First:Even if it is closed, efforts should be made 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.
- Combined with a dedicated landing page:The Anqi CMS provides by default:
errors/close.htmlAs a dedicated site shutdown prompt page.When you set the "Website Status" to "Offline" directly in the "Global Function Settings" on the backend, the system will automatically render and jump to this dedicated offline page.{% system %}Label judgmentSiteCloseTipsThe method is more suitable for a scenario where the website is still accessible but a certain notification needs to be highlighted (such as a module maintenance, rather than a complete site shutdown), or aserrors/close.htmlThe content source of the page. You can choose the most suitable implementation method according to your actual needs, even to directly inject intoSiteCloseTips.errors/close.htmlthe page to achieve unified content management. - SEO considerations:For long-term shutdowns, it is recommended to understand the settings of HTTP status codes. Although the judgment at the template level is mainly for user experience, from the perspective of operation, it is essential to ensure that the search engine receives the correct
503 Service UnavailableStatus code, it can effectively avoid the website 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
English CMS with its flexible template engine and customizable backend settings, allows website operation