In AnQi CMS, it is a key step to improve website user experience and content monetization capabilities by displaying personalized information based on the user's group.The CMS provides a powerful and flexible user group management feature, which can be easily implemented in the front-end template through simple template tag combinations.
Understanding the user group and VIP system of Anqi CMS
One of the core advantages of Anqi CMS is its user group management and VIP system.This means we can classify different permission levels for the website users, such as ordinary users, VIP members, senior VIP members, and so on.These user groups can not only have different operation permissions, but also be associated with specific content access permissions, and even define exclusive VIP levels.userDetailanduserGroupDetail.
Core feature tag parsing
To obtain and display user details and their group information, we will mainly useuserDetailanduserGroupDetailThese tags.
1. Get current user basic information:userDetailtags
userDetailTags are used to retrieve detailed data for specific users.Under user login status, the page context usually provides the ID of the currently logged-in user, which we can use to query the specific information of the user.
The usage of this tag is as follows:{% userDetail 变量名称 with name="字段名称" id="用户ID" %}
Among them:
变量名称: Custom variable name for storing query results, for example,current_user_data.name: Specify the user fields to be retrieved, for example,UserName(Username),GroupId(User Group ID),ExpireTime(VIP expiration time) and so on.id:Specify the user ID to be queried. In practical applications, if it is to display information about the currently logged-in user, this ID is usually provided by the system to the template automatically, for example{{currentUser.Id}}or similar variables.
For example, if we want to get the username and user group ID of the currently logged-in user:
{# 假设当前页面上下文提供了登录用户的信息,例如 currentUser.Id #}
{% userDetail current_user_data with id=currentUser.Id %}
<p>用户名:{{ current_user_data.UserName }}</p>
<p>用户组ID:{{ current_user_data.GroupId }}</p>
{# 可以直接通过 current_user_data.ExpireTime 获取VIP过期时间戳 #}
<p>VIP过期时间戳:{{ current_user_data.ExpireTime }}</p>
2. Query user group details:userGroupDetailtags
userGroupDetailTags are used to get detailed data of user groups. ThroughuserDetailLabel gets the user's informationGroupIdAfter that, we can pass this ID touserGroupDetailLabel, to query the specific information of the user group the user belongs to, such as VIP level, user group name, etc.
The usage of this tag is as follows:{% userGroupDetail 变量名称 with id="用户组ID" %}or{% userGroupDetail 变量名称 with level="用户组等级" %}
Among them:
变量名称:The same as custom variable name, for examplegroup_info.idorlevel:Specify the user group ID or user group level to query, either one can be chosen.
The available fields of this tag include:Title(User group name),Description(Group introduction)、Level(Group level)、Price(Purchase price) etc.
For example, to get the name and level of the user group with ID 1:
{% userGroupDetail vip_group with id="1" %}
<p>用户组名称:{{ vip_group.Title }}</p>
<p>用户组等级:{{ vip_group.Level }}</p>
组合应用:显示用户的VIP等级及过期时间
现在,让我们