In the flexible content management system of AnQiCMS, site operators often need to display some key information of background configuration in the website template according to business requirements.whereas the setting of 'Background independent domain' not only concerns the security of the system, but may also need to be displayed on the website front-end in certain specific scenarios, for example, as an entrance for internal personnel to access quickly, or for information description on specific pages.
Today, let's delve into how to cleverly call and display the independent domain name you configured in the AnQiCMS template in detail.
Understand the independent domain name in the background and its importance
AnQiCMS provides the function of setting an independent domain name for the background, which is crucial for improving system security.Separating the background login address from the website's front-end address can effectively reduce the risk of being scanned and attacked by malicious entities.
You can find and configure in the AnQiCMS backend“Background Settings” -> “Global Function Settings”on the page“backend domain address”This item. Make sure that the domain has been correctly resolved to your server and bound successfully on the server, otherwise you will not be able to access the backend.
Call the background independent domain in the template
AnQiCMS's template system is very powerful and easy to use, it adopts syntax similar to Django template engine. To get various global information of the background settings, we mainly depend onsystemLabel.
systemThe label is used specifically to call the system global configuration. Its basic usage method is{% system 变量名称 with name="字段名称" %}. Among themnameThe parameter is used to specify the configuration item you want to obtain.
Although the document of AnQiCMS does not explicitly list the "background domain address" parameter,namebut according to other system settings (such asSiteName/BaseUrlThe naming convention of ()can be reasonably inferred to be its internal call name:AdminUrl.
Now, let's see how to actually use it in the template:
1. Directly output the independent domain of the background:
If you just want to simply display the backend domain at a certain location on the page, you can do so directly insystemthe label usename="AdminUrl":
<p>您好,内部管理系统入口: <strong>{% system with name="AdminUrl" %}</strong></p>
2. Assign the independent backend domain to a variable and use it:
If you need to process the backend domain obtained, or use it repeatedly in multiple places in the template, you can first assign it to a variable so that the code will be clearer:
{% system adminBackendDomain with name="AdminUrl" %}
{% if adminBackendDomain %}
<p>管理员请点击此处登录:<a href="{{ adminBackendDomain }}" target="_blank" rel="nofollow">{{ adminBackendDomain }}</a></p>
<p>如果您遇到问题,请联系技术支持。</p>
{% else %}
<p>后台管理域名未配置,请联系系统管理员。</p>
{% endif %}
In the above example, we first use{% system adminBackendDomain with name="AdminUrl" %}This background independent domain name has been assigned toadminBackendDomainThis variable. Next, we go through{% if adminBackendDomain %}Determine whether the domain exists (i.e., whether it has been configured in the background), and then proceed with the display. This is a good programming practice that can avoid abnormal display of the page due to missing configuration.
Example of practical application scenarios
- Internal management page prompt:On the page specially prepared for internal staff, the back-end login entry can be clearly displayed, making it convenient for staff to access.
- Enterprise Intranet Portal:In the internal website portal used, AnQiCMS backend can be set as a shortcut entry for one of the internal systems.
- Development debugging information:In the development or testing phase, for convenience, it may be necessary to temporarily display the background domain in the footer, but it must be removed after going live.
- Security Information Disclosure (Special Cases):In very rare cases, to comply with certain security audits or internal regulations, it may be necessary to disclose the separation status of the background domain and the front-end domain.
Precautions
- Considerations for security:It is generally not recommended to directly display the back-end independent domain on public-facing front-end pages unless there is a clear internal requirement. This may increase the risk of the back-end being detected.
- Domain configuration takes precedence:called in the template
AdminUrlEnsure that you have correctly configured the 'Background Domain Address' in the 'Global Function Settings' of the AnQiCMS backend, and that the domain has completed DNS resolution and server binding. If not configured,AdminUrlMay return an empty value or the homepage address plus/system/the suffix, depending on the internal logic of AnQiCMS. - Cache cleaning:Modify the template file and sometimes you need to manually clean the AnQiCMS system cache (
更新缓存Feature) or browser cache to ensure that the new template content takes effect in a timely manner.
By using the above method, you can flexibly call and display the independent domain name in the AnQiCMS template to meet your specific operational needs.The strength of AnQiCMS lies in its high customizability, allowing you to easily manage and display content.
Common Questions (FAQ)
1. If I have not set up a separate domain for the background,AdminUrlwhat will the tag display?
If you have not configured the 'Background Domain Address' in the 'Global Function Settings' of AnQiCMS backend,{% system with name="AdminUrl" %}Labels usually return the root domain of your website plus the default admin path, for examplehttp://yourdomain.com/system/. However, to avoid uncertainty, it is strongly recommended that you always explicitly set a separate admin domain and according to{% if adminBackendDomain %}The judgment and display are performed in the way.
2. Can I directly modify or submit the background domain in the template?
No. The template contains.systemTags are only used for.Reading.Parameters configured by the backend, it is a read-only operation.You cannot modify any backend configuration items through template code, including the independent domain name of the backend.All changes to the background settings must be made through the AnQiCMS management backend interface to ensure data security and system stability.
3. BesidesAdminUrlWhat are some common system information that can be accessedsystemvia tag calling?
systemTags can call many useful global information, such as:
SiteName(Website Name)SiteLogo(Website Logo image address)BaseUrl(Website homepage address)MobileUrl(Website mobile version address, if an independent mobile domain is configured)SiteIcp(Website record number)SiteCopyright(Website copyright information)TemplateUrl(Current template static files (CSS/JS