How to display user details and user grouping information in the AnQiCMS user group management?

Calendar 👁️ 61

In AnQiCMS, effectively managing users and user groups is a key factor in building personalized websites, implementing member strategies, and even achieving content monetization.By flexibly using its built-in template tags, we can easily display users' detailed information and their user group status on the website front-end, providing a more customized and interactive experience.

The 'User Group Management and VIP System' feature provided by AnQiCMS allows website operators to divide different user groups according to business needs and define exclusive permission levels for these groups.Whether it is to provide paid content, build membership services, or simply differentiate between ordinary users and privileged users, user groups play a core role.And presenting these background settings logic information in a friendly manner to the user is an important means to improve user experience and guide users to upgrade their membership.

Flexible display of user details:userDetailThe clever use of tags

When we want to display specific user information on the website front end, AnQiCMS providesuserDetailThe tag can help us obtain rich data such as username, real name, avatar, email, phone number, and even VIP expiration time, account balance, and invitation code.

To useuserDetailtags, we usually specify a user's ID, for example:

{# 假设我们想展示ID为1的用户信息 #}
{% userDetail targetUser with id="1" %}
<div class="user-profile">
    <h2>{{ targetUser.UserName }}的个人主页</h2>
    {% if targetUser.AvatarURL %}
        <img src="{{ targetUser.AvatarURL }}" alt="{{ targetUser.UserName }}的头像" class="user-avatar">
    {% endif %}
    <p>真实姓名:{{ targetUser.RealName }}</p>
    <p>用户邮箱:{{ targetUser.Email }}</p>
    <p>手机号码:{{ targetUser.Phone }}</p>
    <p>账户余额:{{ targetUser.Balance }}</p>
    {# 对于时间戳字段,我们可以使用 AnQiCMS 的 stampToDate 标签进行格式化 #}
    {% if targetUser.ExpireTime %}
        <p>VIP过期时间:{{ stampToDate(targetUser.ExpireTime, "2006年01月02日 15:04") }}</p>
    {% endif %}
</div>
{% enduserDetail %}

In this code block,targetUserIt is the variable name defined for the user detail data we obtain. Through it, we can easily access various user information as if accessing object properties. Especially likeExpireTimeSuch a timestamp field, we can utilizestampToDatelabel, format it into a readable date and time instead of a string of difficult-to-understand numbers.

Reveal user grouping information:userGroupDetailThe power of the label

It may not be enough to just display a user's personal information, often we also need to inform the user of which user group they belong to, as well as the privileges or introduction of that group. At this time,userGroupDetailThe tag comes into play. It can retrieve detailed data such as the name, description, level, and purchase price of the user group based on the user group ID or level.

For example, if we want to display the details of the user group with ID 1:

{# 假设我们想展示ID为1的用户组详情 #}
{% userGroupDetail vipGroup with id="1" %}
<div class="user-group-info">
    <h3>用户组名称:{{ vipGroup.Title }}</h3>
    <p>用户组等级:{{ vipGroup.Level }}</p>
    <p>用户组介绍:{{ vipGroup.Description }}</p>
    <p>原价:{{ vipGroup.Price }}</p>
    <p>优惠价:{{ vipGroup.FavorablePrice }}</p>
    {# 如果后台为用户组设置了自定义配置,可以通过 Setting 字段获取 #}
    {% if vipGroup.Setting.specialBenefit %}
        <p>专属福利:{{ vipGroup.Setting.specialBenefit }}</p>
    {% endif %}
</div>
{% enduserGroupDetail %}

Here, vipGroupIt is used to store group details. Through it, we can clearly display the group name, level, price, and any custom settings in the background (such asspecialBenefit)

Combine users with group information cleverly: Build a personalized user center

The true charm of AnQiCMS lies in its high flexibility, we canuserDetailanduserGroupDetailThese tags combined help users build a rich, dynamic personal center or member status page.

Imagine, after a user logs in, we want to display on their personal dashboard a message like 'Welcome [username], you are a [group name] user', and show their exclusive benefits. This can be achieved in the following way:

”`twig {# Assume the user is logged in, we can directly retrieve the current user details. If you need to specify a user, you can add the id parameter #} {% userDetail currentUser %}

<h2>欢迎您,{{ currentUser.UserName }}!</h2>
<p>您的用户ID:{{ currentUser.Id }}</p>
<p>您的手机号码:{{ currentUser.Phone }}</p>
<p>您的邀请码:{{ currentUser.InviteCode }}</p>

{# 通过当前用户的 GroupId 字段,获取其所属用户组的详细信息 #}
{% userGroupDetail currentGroup with id=currentUser.GroupId %}
<

Related articles

How to safely output HTML code in AnQiCMS templates without escaping?

When building and managing website content, we often need to display rich text content with specific formats or interactive effects on the page, such as the main body of articles, product descriptions, and even embedded video players or maps.AnQiCMS (AnQiCMS) is an efficient and flexible content management system that, when handling these requirements, defaults to taking an important security measure: escaping the HTML code output in the template.

2025-11-07

How to customize the display of image carousel (Banner) through template tags in AnQiCMS?

AnQiCMS as an efficient and customizable enterprise-level content management system has a significant advantage in the flexibility of content display.For the common picture carousel (Banner) feature on the website, AnQiCMS provides various ways to customize the display through template tags, allowing you to easily achieve diverse Banner display effects according to different page and business needs.

2025-11-07

How to display the number of views and comments on articles in AnQiCMS templates?

In website operation, the number of page views and comments on articles is an important indicator of the popularity of content and user engagement.AnQiCMS provides flexible template tag functions, allowing you to easily display these key data on the website front end, thereby better attracting visitors and enhancing content value.

2025-11-07

How to automatically parse the URL string in the text of AnQiCMS to make it clickable?

In daily content operation, we often need to embed various external or internal links in text content such as articles, product descriptions, and even category summaries.However, manually converting each plain text URL string into a clickable HTML link is not only time-consuming and labor-intensive, but also prone to link errors due to negligence, affecting user experience and search engine optimization.

2025-11-07

What is the purpose of the `addslashes` filter in AnQiCMS templates?

During the AnQiCMS template development and content operation process, we often encounter situations where we need to display dynamic content on the web page.This content may come from a database, be entered by a user, or generated by the system.Most of the time, the AnQiCMS template engine automatically escapes output variables for security reasons, converting `<` to `&lt;This effectively prevents common cross-site scripting (XSS) attacks by converting `,`"` to `&quot;` and so on.However, in certain specific scenarios, simple HTML

2025-11-07

The `addslashes` filter adds backslashes to which 'predefined characters'?

In website operation, we often deal with various types of content from different sources, especially when this content is input by users, it may contain some special characters.These characters, if not properly handled, may cause unexpected problems during page display or data transmission, and even destroy the website structure.AnQiCMS provides many practical filters to help us handle these situations, where the `addslashes` filter is a very useful tool, specifically designed to handle predefined characters in strings.

2025-11-07

How to correctly use the `addslashes` filter in AnQiCMS templates?

In AnQiCMS template development, we often need to handle various strings, and how to safely and correctly pass and display strings containing special characters in different environments is a problem that requires careful consideration.The `addslashes` filter is specifically designed to address such specific scenarios.What is the `addslashes` filter?

2025-11-07

What are the escaping rules for single quotes (' ) and double quotes (" ) in the `addslashes` filter?

In the daily content operation of AnQiCMS, we often encounter the need to handle text containing special characters.These special characters, such as single quotes (`'`), double quotes (`"`), and backslashes (`\`), may cause unexpected problems in some scenarios and even pose security risks.To help us better manage and safely display this content, AnQiCMS provides a series of practical template filters, including `addslashes`.

2025-11-07