The `userDetail` tag supports which parameters to accurately find specific user information?

Calendar 👁️ 80

In AnqiCMS template development, in order to display specific user information on the page, we often use a very practical tag -userDetail. This tag allows us to accurately retrieve and present users' detailed data based on specific conditions.Understanding the parameters it supports is crucial for flexibly building user-related page features.

userDetailThe core function of the label is to obtain data based on clear user identification. When in use, it requires us toidThe parameter is used to specify the user ID to be queried. This is a required parameter and ensures the accuracy of the query.For example, if you want to retrieve user information with ID 1, your tag structure will containid="1".

Once we specify the user ID, we can go throughnameParameters to select the specific user fields to be displayed.nameThe parameter is followed by the user data field name we want to obtain. If you want to store the obtained data in a variable, you canuserDetailAfter the tag, specify a variable name, so that the user field can be called through this variable later; if you just want to output the result directly, you can omit the variable name.

Let's take a detailed look atuserDetailWhat user fields are supported by tags and their respective uses:

  • User ID (Id)This is the unique identifier of the user, usually used for internal logic processing.
    • For example:{% userDetail with name="Id" id="123" %}
  • Parent User ID (ParentId)If your system supports user hierarchy or referral relationships, this field will display the parent user ID of the user.
  • Username (UserName)The username or nickname used to display the user's identity on the page.
    • For example:{% userDetail userProfile with name="UserName" id="456" %}{{ userProfile }}
  • Real name (RealName)The real name of the user, which may be used in scenarios requiring real-name authentication.
  • User introduction (Introduce): The user's personal introduction or self-description.
  • User avatar (AvatarURLandFullAvatarURL): Provide the link to the user's avatar image.AvatarURLIt may be a processed thumbnail or a specific size avatar, andFullAvatarURLIt is usually a link to the original or higher resolution avatar.
    • For example:<img src="{% userDetail with name="AvatarURL" id="789" %}" alt="用户头像">
  • User Email (Email): The user's email address.
  • User phone number (Phone): The user's phone number.
  • User Group ID (GroupId)The user's group ID to which the user belongs, which can be used to judge user permissions or identity.
  • Is the user a distributor (IsRetailer)A boolean value indicating whether the user has distribution qualifications.
  • Account balance (Balance)The account balance of the user.
  • Total earnings (TotalReward)The cumulative total earnings of the user on the platform.
  • Invitation code (InviteCode)The exclusive invitation code for the user, used to recommend new users.
  • Last login time (LastLogin)This field displays the time of the user's last login. This field returns a timestamp, and if you need to display it as a readable date format on the page, you need to use thestampToDatetag for formatting.
    • For example:最近登录:{% userDetail loginTime with name="LastLogin" id="101" %}{{ stampToDate(loginTime, "2006-01-02 15:04") }}
  • VIP expiration time (ExpireTime): If the user is a VIP member, this field will display the expiration time of their VIP service. It is also a timestamp and needs to be usedstampToDateFormat labels.
    • For example:VIP到期:{% userDetail vipExpire with name="ExpireTime" id="101" %}{{ stampToDate(vipExpire, "2006年01月02日") }}
  • User link (Link)If the system generates a separate personal homepage link for each user, this field will provide the link.

Through these parameters and fields,userDetailTags provide very fine user information acquisition capabilities. Whether it is to display user nicknames, avatars, or to query their VIP status or recent activity time, it can be achieved through concise template tags.When designing features that need to display user profiles, member centers, or author information in comment sections, this tag can play an important role.

It should be noted that, due touserDetaillabel'sidThe parameter is mandatory, which means you must obtain the target user's ID in some way before calling the tag. This could be through URL parameters, hidden fields on the page, or in combination with other tags such asarchiveDetailofUserIdGet them. Making good use of these parameters can help us build user-friendly website pages more efficiently and accurately.

Frequently Asked Questions (FAQ)

Q1: If I need to get the information of the currently logged-in user,userDetailCan the tag be directly accessed, or do I need to know itsID?

A1: userDetaillabel'sidThe parameter is required, it needs a clear user ID to search and return information.Therefore, the tag itself cannot directly obtain information about the "current logged-in user" because at the template level, the system does not know who is logged in.Generally, if you need to display the information of the currently logged-in user, you need to pass the ID of the current logged-in user to the template on the backend, or asynchronously load the user ID from Session/LocalStorage on the frontend using JavaScript.

Q2:LastLoginandExpireTimeThe field returns a timestamp, how can I display it on the page in a common datetime format?

A2: LastLoginandExpireTimeThe field indeed returns a Unix timestamp. You can use the built-in function of AnqiCMS.stampToDateLabel to format it. This tag requires two parameters: the timestamp variable and the time format string (Go language time format).For example, to display as “2023/01/01 12:30:00”, you can use it like this:{{ stampToDate(user.LastLogin, "2006年01月02日 15:04:05") }}.

Q3: Can I useuserDetailTag to retrieve information about multiple users at once, or search based on username or other fields?

A3: userDetailThe label is primarily designed to accurately retrieve detailed information about a single user and must be accessed through the user ID (idThe parameter is specified. It does not directly support retrieving multiple users in bulk or searching based on username or other non-ID fields.If your requirement is to display a list of users in bulk, or to filter users based on other conditions, this usually requires combining backend development, through custom list tags or API interfaces to achieve.

Related articles

How to use the `userDetail` tag to retrieve the user's real name `RealName` on the frontend page?

In website operations, personalization and user experience are the key to enhancing brand image.Sometimes, we are not satisfied with just displaying the user's nickname or avatar. In certain scenarios, such as the member center, profile page, or some activity leaderboard, we may also need to display the user's real name.AnQi CMS is a highly flexible and feature-rich Go language content management system that provides intuitive template tags, allowing front-end developers to easily retrieve and display this information.Today, let's delve into how to use the `userDetail` tag of Anqi CMS

2025-11-07

How to correctly display the user's `UserName` (username) in the AnQiCMS template?

In AnQiCMS templates, flexibly displaying user information is a key link to enhance website personalization and user experience.Whether it is to display the nickname of the comment author or to show the detailed information of the registered user on a specific page, it is very important to understand how to correctly call `UserName`. AnQiCMS's powerful template engine provides multiple ways to achieve this goal, and we will delve deeper into these methods next.AnQiCMS's template system adopts a syntax similar to the Django template engine, which allows developers to quickly build pages in a concise and efficient manner

2025-11-07

How to use the `userDetail` tag to obtain and display the ID information of a specified user?

AnQiCMS with its flexible and powerful template tag system makes the display of website content very convenient.Whether it is articles, products, or user information, they can be easily displayed on the page with simple tags.Today, let's talk about how to use the `userDetail` tag to accurately obtain and display the ID information of a specified user.

2025-11-07

How to display the link to the previous and next article on the AnQiCMS article detail page?

To add links to the previous and next articles on the article detail page in AnQi CMS is a very practical feature for enhancing user reading experience and the internal link structure of the website.AnQiCMS's powerful template tag system makes this feature intuitive and efficient.

2025-11-07

How to format `LastLogin` (last login time) into a readable date using the `stampToDate` tag?

In website operation and management, user behavior data is an important basis for improving user experience and formulating strategies.Among them, the "LastLogin" is a direct indicator of user activity.However, this data is usually stored in the form of raw timestamps, and for ordinary users, a string of numbers is far less friendly and understandable than a direct date and time.AnQi CMS provides powerful template tag functions, among which the `stampToDate` tag is a powerful tool to solve this problem, it can help us easily convert abstract timestamps into clear and readable date formats

2025-11-07

How to dynamically display exclusive content for distributors based on the user's `IsRetailer` status in AnQiCMS templates?

Today, providing customized experiences for users of different types has become the key to improving user satisfaction and business efficiency.For businesses with a distribution system, how to ensure that distributors can easily access their exclusive content without causing interference to ordinary users is a common need.AnQiCMS with its flexible template engine and powerful user management features, can help you easily achieve this goal.

2025-11-07

How to get the user's account balance `Balance` and cumulative earnings `TotalReward` through the `userDetail` tag?

How to retrieve and display a user's account balance and cumulative earnings in AnQi CMS template?For operators, it is a key element to enhance user experience and manage the membership system by flexibly displaying user-specific information on the website, such as their account balance or cumulative earnings.AnQi CMS is a powerful and practical content management system that provides a very convenient way to obtain these user data.Today, let's talk about how to use your template

2025-11-07

Can the `userDetail` tag retrieve the user's email `Email` and phone number `Phone` and display it on the front end?

In website operation and user experience design, sometimes we need to display specific user information on the front-end page, such as contact email or phone number, in order to provide personalized services or facilitate users to view/update their personal information.It is crucial for users of AnQiCMS to understand how to implement this safely and efficiently.This article will delve into the `userDetail` tag of AnQiCMS, discussing whether it can retrieve and display the user's email (`Email`) and phone number (`Phone`), as well as the matters that need to be paid attention to during use

2025-11-07